Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 7:47 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Detect/Set TWL Focus?
PostPosted: Thu Mar 11, 2010 9:10 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Is there a way to detect/set focus on TWL windows?


Top
 Profile  
 
PostPosted: Thu Mar 11, 2010 10:30 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
dime wrote:
Is there a way to detect/set focus on TWL windows?

look at Widget.requestKeyboardFocus(). The widget needs to be part of the GUI tree (eg getGUI() needs to return a GUI instance).
If you want to remove the keyboard focus from all child widgets call Widget.requestKeyboardFocus(null).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Mon May 10, 2010 2:03 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
If you want to remove the keyboard focus from all child widgets call Widget.requestKeyboardFocus(null).


that method is protected:

protected boolean requestKeyboardFocus(Widget child)
A child requests keyboard focus.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2010 3:07 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Also is there a way to unfocus an entire windows (widget)?

When I first start TWL, nothing is focused (which is good). Is there a way to get back to that non-focused state?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2010 6:16 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
Just call giveupKeyboardFocus() on a widget. It will still remember which of it's children had focus if you call requestKeyboardFocus() on it the next time.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2010 6:29 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
ok, got it. If I call give giveupKeyboardFocus() on the DesktopArea() it "un focuses" all windows which is what I want. Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group