News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Space Bar presses FLTK buttons
Author Message
MrBill
Junior Member
**


Posts: 14
Group: Registered
Joined: Mar 2008
Status: Offline
Reputation: 0
Post: #1
Space Bar presses FLTK buttons

How to prevent this odd behavior?
There must be some setting I don't know about.

I have a button that opens a window, when I select a button on that window I thought closing the window would prevent its button from being hit twice, however the button on the first window gets hit and the window opens again.

Any ideas?

09-17-2008 06:01 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #2
RE: Space Bar presses FLTK buttons

I'm not clear on what the situation is, but it sounds like a focus problem?

Space bar on a selected button will, as far as I know, always trigger the callback of that button.

You might need to override the default behavior by checking events, but like I said I'm not sure exactly what your issue is.

09-17-2008 08:49 AM
Find all posts by this user Quote this message in a reply
MrBill
Junior Member
**


Posts: 14
Group: Registered
Joined: Mar 2008
Status: Offline
Reputation: 0
Post: #3
RE: Space Bar presses FLTK buttons

Well how can I make sure nothing is focused?

I did a little hack to make sure this particular button doesn't execute its default command every single time its pressed, but its hacky at best and I still have instances where the space bar grabs a button I don't want it to grab.

Basically this button in question is loading a game level, so I tested to see if the level was loaded and game mode was set, then it won't freak out. However I have another interface where a button sets the camera mode, after you turn the button/camera off, hitting the space bar gets the button again! This happens when in game mode and the game script is polling the space bar for something, like jumping.

Ideally there must be a way to deselect a whole interface or prevent the space bar from doing its wacky button press. I tried hiding the button in question, FLTK then pressed the next button available with space bar.

I suppose I could check the keyboard and then exit my functions if the space key has been pressed? Ah the simple solution becomes clear in the daylight.

09-18-2008 04:10 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #4
RE: Space Bar presses FLTK buttons

Have you tried disabling the buttons while the game is active ?

09-18-2008 06:45 AM
Visit this user's website Find all posts by this user Quote this message in a reply
MrBill
Junior Member
**


Posts: 14
Group: Registered
Joined: Mar 2008
Status: Offline
Reputation: 0
Post: #5
RE: Space Bar presses FLTK buttons

This at the start of the button function worked:

Code:
if Fl:event_key() == 32 then return end


Dropped right out of the callback without causing any problems.

Is there some command that just disables a thing?
The only enable/disable I find is for tooltips.

I tried hiding the button, and setting its
object reference to nil, that sent focus to the button that was
pressed before that. Closing the window sent focus to the
previous button on the previous window.

09-18-2008 04:47 PM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #6
RE: Space Bar presses FLTK buttons

my_button:deactivate()
but I believe this will do the same as hiding, just shifting focus to the next widget.
You can put ALL your buttons into a single group and disable everything in one swell foop with my_group:deactivate()

Or, you can try to force focus to a dummy widget.

This post was last modified: 09-18-2008 10:38 PM by mikshaw.

09-18-2008 10:38 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: