Finally got some more time to work on this.  The workaround I have found to 
this problem is to add this somewhere in the main loop:

gui.mOutput->throw_focus();

the fltk::Output will steal key events for Delete, Backspace, Ctrl, and a few 
others.  I'm not sure why this should happen.  I can understand why 
fltk::Output should take the Tab key event if you are tabbing through widgets, 
but I don't know why it needs some of these other events.  Perhaps 
Output::handle() should return 0 for some of these keys instead of letting them 
fall through to Input::handle().

- Terry

> > On 30/11/11 08:20, Terry Welsh wrote:
> > > Hi,
> > > I'm using FLTK 2, and I have a class derived from GlWindow.  My handle() 
> > > function gets called for almost every key on the keyboard, but not when I 
> > > press backspace or delete.  Is this expected behavior?  Is there a way to 
> > > get events for these keys?
> >
> > Urgh, I'm not even sure. So in theory, the answer to "Is this expected?"
> > is no, while "is there a way to get events for these keys?" is yes.
> > However:
> > OpenGL compatibility with FLTK2 (especially with keyboards and whatnot)
> > is achieved by emulating certain bits of OGL functionality, to make it
> > work properly with fltk. As such, there are a few really dirty hacks
> > going on to (try to) make things work as they should. Occasionally,
> > however, things stop working.
> >
> > However, in saying that this doesn't automagically make fltk the
> > problem; there could be a whole raft of issues to do with your platform,
> > or code, or etc.
> > If you could post a minimal, compilable example of your current code
> > that shows the problem, this would be fantastic. I'll take a look if I
> > get the time, though at the moment that's a rather large if.
> > In the meantime, I'd suggest using fltk1.3 -- this is far far more
> > stable than 2.0 and is less likely to have as many bugs. If you really
> > desperately need 2.0 compatibility, you'll probably want to wait until
> > fltk3 comes out (and I get the 2.0 compatibility layer in, too, though
> > like I said I'm struggling for time at the moment).
> >
> > HTH,
> > Ben
> >
>
> Hi Ben,
> Thanks for the reply.  BTW, my platform is Suse 11.3 and Gnome 2.x.  Below is 
> the minimal test case you asked for.  It appears the problem is introduced by 
> having an fltk::Output beside the GlWindow.  If you comment out the creation 
> of the fltk::Output, then the Backspace and Delete keys will work.  Changing 
> the GlWindow to a regular Window does not help.  I found other keys that fail 
> in the presence of the fltk::Output:  Esc Tab, Shift, Ctrl, Home, and End.
>
> That's as far as I've gotten.  I'll try other Linux distros and desktop 
> enviroments and dig into the fltk code when I get a little more time to work 
> on this.  Any suggestions would be great.
>
> We started this project years ago when 2.0 was supposed to be the future.  
> Switching to 1.3 sounds more difficult than they'll give me time for.  You're 
> probably right that 3.0 is the way to go eventually.  (Funny how people here 
> talk about 2.0 as unstable, since it's still the most stable open source 
> project I've ever used.)
>
>
> #include <fltk/GlWindow.h>
> #include <fltk/Output.h>
> #include <fltk/events.h>
> #include <fltk/run.h>
> #include <iostream>
>
>
> using namespace std;
> using namespace fltk;
>
>
> class MyView : public fltk::GlWindow{
> public:
>       MyView(int x, int y, int w, int h, const char *l)
>               : GlWindow(x, y, w, h, l) {}
>       ~MyView(){}
>
>       void draw(){}
>
>       int handle(int e){
>               switch(e){
>               case fltk::SHORTCUT:
>                       cout << fltk::event_key() << endl;
>                       break;
>               }
>
>               return (GlWindow::handle(e));
>       }
> };
>
>
> class MyGui{
> public:
>       Window* mMainWindow;
>       MyView* mMyView;
>       Output* mOutput;
>
>       MyGui(){
>               Window* o = mMainWindow = new Window(400, 400, "FLTK delete key 
> test");
>               o->shortcut(0xff1b);
>               o->user_data((void*)(this));
>               o->begin();
>
>                       mMyView = new MyView(0, 0, 400, 375, "");
>                       Group::current()->resizable(mMyView);
>
>                       mOutput = new fltk::Output(0, 375, 400, 25);
>
>               o->end();
>       }
>
>       ~MyGui(){}
>
>       void show(){
>               mMainWindow->show();
>       }
> };
>
>
> int main(int argc, char* argv[]){
>       MyGui gui;
>       gui.show();
>
>       while(1){
>               fltk::check();
>       }
>
>       return 0;
> }

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to