I'm guessing your "UI" class is not actually derived
from an FLTK widget. If so, that's the reason your
handle() method isn't being called; FLTK doesn't know about it.

What you need is to make a class that /derives/ from an FLTK widget,
and define your handle(int) method there, so that it /overrides/
fltk's own internal handle() method.

Look at this example which shows just that:
http://seriss.com/people/erco/fltk/#GLCursor

This example derives a class "MyGlWindow" that derives from
Fl_Gl_Window (in this case, but could just as easily be an Fl_Window)
and defines a handle() method to override Fl_Gl_Window's own.

Note that the handle() method calls Fl_Gl_Window::handle(e) to pass
the event down to the derived class's handle() method, so that the
underlying class gets a shot at processing the event too. Be sure
yours does this, and preserves the return value for the handle()
method, which is very important.

In your case you can probably get what you want by leaving your
existing UI class alone, but make a separate new class
called MyGlutWindow, in a file called MyGlutWindow.H, eg:

#include <FL/Fl_Window.H>                       // include the widget..
class MyGlutWindow : public Fl_Window {         // ..that you derive from
public:
    MyGlutWindow(int X,int Y,int W,int H,const char *L=0) : 
Fl_Window(X,Y,W,H,L) {
    }
    int handle(int e) {
        ..do your event handling here..
    }
};

Then in fluid, open the 'Properties' for the FLTK window you're
trying to grab the events for, and under the C++ tab in the properties dialog,
set the Class: to MyGlutWindow.

Make sure your fluid file has a "#include <MyGlutWindow.H>",
so that when fluid writes out the code, that include is always
saved into the .cxx and/or .h file that fluid generates.

This way fluid will use your derived window class instead of Fl_Window
in your ui->make_window() call.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to