Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2011, 06:51 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
"Safe", non-focus stealing GUIControls?

I've been using this to ensure that a GUIControl will never steal key input, but it still does?

PHP Code:
profile.cankeyfocus false
I still need to be able to interact with it through mouse input, and setting

PHP Code:
profile.modal false
removes the ability to use the GUIControl via mouse, but remedies the key input problem. Can anybody help me out here?
Reply With Quote
  #2  
Old 07-25-2011, 08:16 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
GraalControl.makeFirstResponder(true); after initializing the GUIs
Reply With Quote
  #3  
Old 07-25-2011, 12:15 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
PHP Code:
function onFirstResponderChanges(obj)
{
  if (
obj.objecttype() in "GuiButtonCtrl""GuiBitmapButtonCtrl" })
    
GraalControl.makefirstresponder(true);
  
  
//player.addMessage("New first responder:" SPC obj SPC "(" @ obj.objecttype() @ ")");

Only an example, but hey it works.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 07-25-2011, 10:51 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
profile.modal = false;
profile.cankeyfocus = false;
profile.focusonshow = false;
profile.tab = false;
Reply With Quote
  #5  
Old 07-27-2011, 03:07 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
PHP Code:
temp.lastFocus GraalControl;
for (
GraalControl.controls) {
  if (
c.isFirstResponder()) {
    
temp.lastFocus c;
    break;
  }
}

//Create GUIControl

temp.lastFocus.makeFirstResponder(true); 
I figured that would be a better way. Is that more reliable (i.e. works with chatbar and other GUIControls), or can more than one object return true from isFirstResponder()?
Reply With Quote
  #6  
Old 07-27-2011, 04:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Hezzy002 View Post
PHP Code:
temp.lastFocus GraalControl;
for (
GraalControl.controls) {
  if (
c.isFirstResponder()) {
    
temp.lastFocus c;
    break;
  }
}

//Create GUIControl

temp.lastFocus.makeFirstResponder(true); 
I figured that would be a better way. Is that more reliable (i.e. works with chatbar and other GUIControls), or can more than one object return true from isFirstResponder()?
That would only check the first children of GraalControl, so, for example, a button inside a window would not be checked.

If it's absolutely necessary, I'd do something like this.

PHP Code:
function onFirstResponderChanges(temp.obj) {
  if (
temp.obj.dontStealFocus) {
    
this.lastResponder.makeFirstResponder(true);
  } else {
    
this.lastResponder temp.obj;
  }

Then you could just set dontStealFocus on any GUI control and it wouldn't steal focus.
__________________
Reply With Quote
  #7  
Old 07-27-2011, 06:16 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by cbk1994 View Post
That would only check the first children of GraalControl, so, for example, a button inside a window would not be checked.

If it's absolutely necessary, I'd do something like this.

PHP Code:
function onFirstResponderChanges(temp.obj) {
  if (
temp.obj.dontStealFocus) {
    
this.lastResponder.makeFirstResponder(true);
  } else {
    
this.lastResponder temp.obj;
  }

Then you could just set dontStealFocus on any GUI control and it wouldn't steal focus.
Sounds perfectly ideal, thanks for the suggestion mate.
Reply With Quote
  #8  
Old 02-02-2012, 10:04 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Stefan View Post
profile.modal = false;
profile.cankeyfocus = false;
profile.focusonshow = false;
profile.tab = false;
From what I've tested this only seems to work when you have no keys pressed down at the time the GUI is created. If you're holding down an arrow key for example focus will still be stolen.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.