Livia Koch wrote:
> I have subclassed Fl_Gl_Window (class My_Window) and written an own
> handle-function. It works fine, but recently I have made a new subclass
> My_Window_2 to my first subclass. As a handle function, it is still
> calling My_Window::handle(int event).
> For My_Window_2 dragging doesn't work. FL_PUSH and FL_RELEASE are
> recognized correctly, however inbetween handle isn't called anymore.
> Do you have any suggestions?
Be sure your widgets are passing events down to the base class.
Note that when you define a handle() method, it becomes your
responsibility to pass all events down to the base class,
otherwise the events will be eclipsed from the base class's visibility.
The way your handle() is currently written, the events MOUSEWHEEL,
PUSH, DRAG and RELEASE are all being eclipsed from the base class,
because the code is returning, without ever calling
Fl_Gl_Window::handle().
Offhand, I'd suggest always passing the event down to the
base class first. So if your widget is subclassing from Fl_Gl_Window,
it should look more like this:
int My_Window::handle(int event) {
int ret = Fl_Gl_Window::handle(event); // MAKE SURE EVENT GETS TO
WIDGET
switch ( event ) {
case FL_MOUSEWHEEL:
cout << "FL_MOUSEWHEEL" << endl;
ret = 1;
break;
case FL_PUSH:
cout << "FL_PUSH" << endl;
ret = 1;
break;
case FL_DRAG:
cout << "dragging" << endl;
ret = 1;
break;
case FL_RELEASE:
cout << "FL_RELEASE" << endl;
ret = 1;
break;
}
return(ret);
}
And if you subclass /another/ class from the above My_Window class,
lets say its called My_Meta_Window, then it's handle method should
look like this:
int My_Meta_Window::handle(int event) {
int ret = My_Window::handle(event); // MAKE SURE EVENT GETS TO
My_Window::handle()
..
return(ret);
}
So always keep in mind that defining a handle() for a widget
will /eclipse/ the events from the immediate base class
unless you pass them through. (This allows you to eclipse events
if you need to, but in most cases you don't want to do that,
as the base class more often then not needs all events so they
can be passed down to the children.)
If that still doesn't help, see if you can make a simple 2 window
app that demonstrates the problem, and send us the code for that app,
so we can really see what's going on.
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl