Harvey Chapman wrote:
> fltk-1.3.x-r6916
>
> I have a window with only one active item, a button (not counting
> three active, but empty groups). When the mouse leaves the entire
> window, I get a FL_LEAVE event over and over again, i.e. each time the
> mouse leaves the entire window. It doesn't hurt anything, but it
> doesn't seem correct either since the mouse never FL_ENTERed the
> button to begin with.
To reliably receive ENTER/LEAVE events, be sure your handle() method
returns 1 in response to both, eg:
int MyButton::handle(int e) {
int ret = Fl_Button::handle(e);
switch (e) {
case FL_ENTER: ret = 1; break;
case FL_LEAVE: ret = 1; break;
:
}
return(ret);
}
..this, as per the docs on FL_ENTER and FL_LEAVE:
http://fltk.org/doc-1.3/events.html
FL_ENTER
The mouse has been moved to point at this widget. This can be used
for highlighting feedback. If a widget wants to highlight or otherwise
track the mouse, it indicates this by returning non-zero from its
handle() method. It then becomes the Fl::belowmouse() widget and
will receive FL_MOVE and FL_LEAVE events.
FL_LEAVE
The mouse has moved out of the widget.
In order to receive the FL_LEAVE event, the widget must return
non-zero when handling FL_ENTER.
> Here's a fluid file to demonstrate the behavior.
> Function {fl_event_name(enum Fl_Event event)} {open selected
> return_type {static const char *}
> } {
> code {switch (event)
> {
> \#define PEVENT(_E) case _E: return(\#_E)
> PEVENT(FL_NO_EVENT);
> PEVENT(FL_PUSH);
> PEVENT(FL_RELEASE);
> PEVENT(FL_ENTER);
> PEVENT(FL_LEAVE);
> PEVENT(FL_DRAG);
> [..]
> PEVENT(FL_DND_ENTER);
> PEVENT(FL_DND_DRAG);
> PEVENT(FL_DND_LEAVE);
> PEVENT(FL_DND_RELEASE);
> \#undef PEVENT
> }
In place of the above, I believe you can use:
#include <FL/names.h>
:
printf("Event %d is %s\n", e, fl_eventnames[e]);
See:
http://fltk.org/doc-1.3/names_8h-source.html
I don't think there are docs for this, but there should be.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk