Harvey Chapman wrote:
> On Oct 21, 2009, at 4:52 PM, Greg Ercolano wrote:
>>      To reliably receive ENTER/LEAVE events, be sure your handle() method
>>      returns 1 in response to both, eg:
> 
> Thanks, my problem was that I was receiving LEAVE events when I  
> shouldn't have been. My follow-up e-mail with patch should show that  
> this behavior was ismply a possible bug in Fl_Group.cxx.

        The events you describe /might/ be intentional, such as to ensure the
        widget gets a leave event if the mouse travels off the widget via a
        sneaky route, say off a popup menu and from there, off the window.

        Or it might be a bug.. if you're sure, post it via the STR form
        so that it gets into the bug list and gets investigated.

        From what I gather reading the docs, to get predictable events from
        FL_ENTER and FL_LEAVE, you have to return 1. (And if you don't, it
        seems to stand to reason you'd get 'unpredictable' behavior.)

        So to play by the rules try the following and see if this at
        least gets you /predictable/ results that you can use.

        I do get the extra FL_LEAVE's, but I also get predictable FL_ENTER's.
        Works for me on Linux, but have not tried it on windows.

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/names.h>
class MyButton : public Fl_Button {
public:
    MyButton(int X,int Y,int W,int H,const char *L=0) : Fl_Button(X,Y,W,H,L) {
    }
    int handle(int e) {
        int ret = Fl_Button::handle(e);
        if ( e != FL_MOVE )                     // too much info
            { printf("%s: Event #%d - %s\n", label(), e, fl_eventnames[e]); }
        switch (e) {
            case FL_ENTER: ret = 1; break;
            case FL_LEAVE: ret = 1; break;
        }
        return(ret);
    }
};
int main() {
    Fl_Window win(720, 486);
    win.begin();
    MyButton b1(10,10,120,25,"A");
    MyButton b2(10,40,120,25,"B");
    win.end();
    win.show();
    return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to