| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #1639
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 4 - High, e.g. key functionality not working |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Documentation |
Summary: | Fl::event_button[1,2,3]() always returns 0 |
Version: | 1.1.7 |
Created By: | scorpion007 |
Assigned To: | matt |
Fix Version: | 1.1-current (SVN: v5786) |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | scorpion007 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 number (1,2,3).
static void button_cb(Fl_Widget *w, void *v) { MyApp *app = (MyApp *)v; if (Fl::event_button() == FL_LEFT_MOUSE) { app->addNum(); } else { 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) | |
|
#2 | scorpion007 17:21 Mar 24, 2007 |
| Forgot to mention, I'm using Win32. | |
|
#3 | greg.ercolano 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. | |
|
#4 | matt 07:12 May 01, 2007 |
| STR #1639: improved documentation to explain the difference between evnt_button() and event_buttons() | |
[ Return to Bugs & Features ]
|
| |