[ Return to Bugs & Features | Roadmap 1.1 ]
|Status:||1 - Closed w/Resolution|
|Priority:||4 - High, e.g. key functionality not working|
|Scope:||3 - Applies to all machines and operating systems|
|Summary:||Fl::event_button[1,2,3]() always returns 0|
|Fix Version:||1.1-current (SVN: v5786)|
Trouble Report Files:
Trouble Report Comments:
17:20 Mar 24, 2007
|Calling either of these functions inside an event callback for a button, while pressing either of the 3 mouse buttons returns false (0). |
Yet, when I call Fl::event_button() it returns the correct button
static void button_cb(Fl_Widget *w, void *v)
MyApp *app = (MyApp *)v;
if (Fl::event_button() == FL_LEFT_MOUSE)
printf("button %d was pressed (%d, %d, %d)\n", Fl::event_button(),
Fl::event_button1(), Fl::event_button2(), Fl::event_button3());
If I right- or middle-click, I get the following output:
button 3 was pressed (0, 0, 0) // <- all zero's inside the brackets
button 2 was pressed (0, 0, 0)
button 3 was pressed (0, 0, 0)
17:21 Mar 24, 2007
|Forgot to mention, I'm using Win32. ||
18:23 Mar 24, 2007
|Just some notes from the sidelines, as I thought this was interesting. |
I think the problem here is the functions in question [event_button123()] all work with the event_state(), which returns the buttons being held down at the time of the event.
Since the button callback is called when buttons are /released/, the event_state() has already been cleared.
The functions in question work OK in the context of handle() in response to an FL_PUSH, but return all 0's when FL_RELEASE occurs because the button is no longer down.
Or so it seems, looking at how the event_button123() and event_buttons() [plural] methods work.
The event_button() [singluar] and event_key() methods have a different implementation that doesn't look at the event_state(), but rather, the event e_keysym.
Not sure if this is a bug in the code, or an undocumented or misdocumented feature.. as the docs for the 'Fl::event_*() methods' section say these methods are valid in handle() and callback() contexts.. just apparently not in the context of a button callback() though.
07:12 May 01, 2007
|STR #1639: improved documentation to explain the difference between evnt_button() and event_buttons() ||
[ Return to Bugs & Features ]