From b5d1c1c887f0af7cee8f30ace285ac1d35c5594a Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 22 Feb 2002 17:40:58 +0000 Subject: [PATCH] Fix event handling for arrow keys in Opengl_Window (required only for FLTK >= 1.1) --- Fltk/GUI.cpp | 18 ++++++++++++++---- Fltk/GUI.h | 1 + Fltk/Opengl_Window.cpp | 19 ++++++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 41d4da70f0..8dcaa2a452 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.155 2002-02-22 16:44:09 geuzaine Exp $ +// $Id: GUI.cpp,v 1.156 2002-02-22 17:40:58 geuzaine Exp $ // To make the interface as visually consistent as possible, please: // - use the IW, BB, BH, BW and WB values @@ -506,7 +506,19 @@ int GUI::global_shortcuts(int event){ show = !show; return 1; } - else if(Fl::test_shortcut(FL_Left)){ + else if(arrow_shortcuts()){ + return 1; + } + + return 0; +} + +// Test the arrow shortcuts (this is not in the global_shortcuts) +// since it is used elsewhere (where we want to override widget +// navigation: necessary since FLTK>=1.1) + +int GUI::arrow_shortcuts(){ + if(Fl::test_shortcut(FL_Left)){ ManualPlay(1,-1); return 1; } @@ -522,8 +534,6 @@ int GUI::global_shortcuts(int event){ ManualPlay(0,1); return 1; } - - return 0; } diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 3360c63f2a..9da8e84eb5 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -234,6 +234,7 @@ public: void set_title(char *str); void add_handler(); int global_shortcuts(int event); + int arrow_shortcuts(); void reset_visibility(); int selection, try_selection, quit_selection, end_selection; diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp index 83ea8aca71..f259b9e828 100644 --- a/Fltk/Opengl_Window.cpp +++ b/Fltk/Opengl_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl_Window.cpp,v 1.19 2001-11-19 14:24:02 geuzaine Exp $ +// $Id: Opengl_Window.cpp,v 1.20 2002-02-22 17:40:58 geuzaine Exp $ #include "Gmsh.h" #include "Numeric.h" @@ -114,6 +114,23 @@ int Opengl_Window::handle(int event) { switch (event) { + case FL_ENTER : + take_focus(); //force keyboard focus on the Opengl_Window + return 1; + + case FL_LEAVE : + case FL_FOCUS : + case FL_UNFOCUS : + return 1; + + case FL_SHORTCUT : + case FL_KEYBOARD : + // this overrides the default navigation + if(WID->arrow_shortcuts()){ + return 1; + } + return Fl_Gl_Window::handle(event); + case FL_PUSH: FirstClick = 1; ibut = Fl::event_button(); -- GitLab