The window class (and group for that matter) is responsible for sending 
events to the children, so do not override window handle() unless it 
also handless sending the events to its children. Override handle() 
only  for your new box class - something like this:

int My_Box::handle(int event){
   swich(event){
   case FL_ENTER:
      do_something_for_enter();
      return 1;
   case FL_MOVE:
      do_something_for_move();// using Fl::event_x() and Fl::event_y();
      return 1;
   case FL_LEAVE:
      do_something_for_leave();
      return 1;
   ...
   }
   return 0; // unknown event, not intrested in it,
             // let the parent group send it elsewhere...
}

Note that the code for FL_ENTER and FL_MOVE can be the same - when the 
FL_MOVE event coordinates are inside the widget. You can either use a 
flag which is set for FL_ENTER and reset for FL_LEAVE events or use 
Fl::event_inside(this) for checking.

R.


Lukasz wrote:
> Hi,
> In my program there is a window widget derived form Fl_Window and its child, 
> box widget, derived from Fl_Box. I would like both of them to have their own 
> handle() functions. However, if I don't declare handle() for window, box gets 
> events (so everything's fine), but if I declare even empty (and always 
> returning 0) handle() for window, box doesn't get _any_ event.
> 
> So, what's the right way to have actually multiple handles()? I would like 
> the box widget to react on FL_ENTER and FL_MOVE, and I would prefer not to 
> send these events "manually" from within window::handle() after checking 
> whether mouse is above the box widget.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to