Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   "Safe", non-focus stealing GUIControls? (https://forums.graalonline.com/forums/showthread.php?t=134264003)

Hezzy002 07-25-2011 06:51 AM

"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?

Mark Sir Link 07-25-2011 08:16 AM

GraalControl.makeFirstResponder(true); after initializing the GUIs

xXziroXx 07-25-2011 12:15 PM

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.

Admins 07-25-2011 10:51 PM

profile.modal = false;
profile.cankeyfocus = false;
profile.focusonshow = false;
profile.tab = false;

Hezzy002 07-27-2011 03:07 AM

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()?

cbk1994 07-27-2011 04:15 AM

Quote:

Originally Posted by Hezzy002 (Post 1660513)
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.

Hezzy002 07-27-2011 06:16 AM

Quote:

Originally Posted by cbk1994 (Post 1660518)
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.

ffcmike 02-02-2012 10:04 PM

Quote:

Originally Posted by Stefan (Post 1660319)
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.


All times are GMT +2. The time now is 01:52 PM.

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