Greg also posted a reply so I'll just answer both in here.
The problem I had, was that a widget that I was using periodically generated
TIMEOUT events and responded to them in the same handler method. As a result,
any other widget in the program could induce an effect in this widget. For
example, if I had a callback method that opened a new window and just clicked
in that window it affected my widget. (The widgets 'timer' was sampling
non-related events and handling them.)
I fixed the problem by decoupling the 'timer' into a dummy class whose only job
is to generate and send TIMEOUT events to 'registered widgets'.
Next, I had to qualify each handled event with (... && event_inside(*this)) so
that my widget knows the event occurred with respect to it.
Third, using "return Widget::handle(e);" produced strange behavior for my
application. My widget is supposed to synchronously sample the state of mouse
buttons 1 and 3 (via the timer) but also respond asynchronously to the middle
mouse button. I can only get the widget to behave using "return 1;".
Perhaps I'm misusing event handling but my app is working correctly and
consistently. Thanks for the responses...
Regards,
Larry
>
> On 25 Oct 2008, at 2:50, Larry Navarro wrote:
>
> > int handle(int event) {
>
> > return 1;
>
>
> I suspect you are confusing fltk's event handling by simply *always*
> returning non-zero here.
>
> Your widget will be offered many types of events (enter/leave/focus/
> etc/etc) and since you are grabbing everything that comes your way,
> then a lot of follow-on events will be sent to your widget also. I'd
> guess that is what is happening here.
>
> Basically, you want to return 0 for any event you are offered, unless
> you *really do* use it. In practice, it is also a Good Idea to call
> the base class handle method (and recording the result) before doing
> your own thing, so that it can do any other event tasks that are
> required.
>
> Hope that made some sort of sense, and was helpful!
> Cheers,
> --
> Ian
>
>
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk