From 7fffbf7deaae186c2e869c87e2d0fead17299efa Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 29 Oct 2006 13:22:28 +0000 Subject: Shortcut events could be sent to the wrong window (STR #1451) src/Fl.cxx: - Fl::event_inside(): Only return true for widgets if the first_window() (focused window) is the same as the widget's window. - Fl::handle(): Send shortcuts to the first window (that has focus) before all others. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5531 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/Fl.cxx | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 527386132..03bab4412 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ CHANGES IN FLTK 1.1.8 + - Shortcut events could be sent to the wrong window (STR + #1451) - Fl_Spinner did not handle the arrow keys properly (STR #1476) - Fl_File_Browser did not calculate the width of diff --git a/src/Fl.cxx b/src/Fl.cxx index 930c95a66..ec0196b52 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -106,6 +106,7 @@ int Fl::event_inside(int xx,int yy,int ww,int hh) /*const*/ { } int Fl::event_inside(const Fl_Widget *o) /*const*/ { + if (first_window() != o->window()) return 0; int mx = e_x - o->x(); int my = e_y - o->y(); return (mx >= 0 && mx < o->w() && my >= 0 && my < o->h()); @@ -795,7 +796,8 @@ int Fl::handle(int e, Fl_Window* window) if (send(FL_KEYBOARD, wi, window)) return 1; // recursive call to try shortcut: - if (handle(FL_SHORTCUT, window)) return 1; + if (handle(FL_SHORTCUT, first_window())) return 1; + else if (first_window() != window && handle(FL_SHORTCUT, window)) return 1; // and then try a shortcut with the case of the text swapped, by // changing the text and falling through to FL_SHORTCUT case: @@ -807,9 +809,18 @@ int Fl::handle(int e, Fl_Window* window) case FL_SHORTCUT: if (grab()) {wi = grab(); break;} // send it to grab window - // Try it as shortcut, sending to mouse widget and all parents: - wi = belowmouse(); if (!wi) {wi = modal(); if (!wi) wi = window;} - for (; wi; wi = wi->parent()) if (send(FL_SHORTCUT, wi, window)) return 1; + // Try it as shortcut, sending to focused window then mouse widget and + // all parents: + if (send(FL_SHORTCUT, first_window(), first_window())) return 1; + + wi = belowmouse(); + if (!wi) { + wi = modal(); + if (!wi) wi = window; + } + for (; wi; wi = wi->parent()) { + if (send(FL_SHORTCUT, wi, wi->window())) return 1; + } // try using add_handle() functions: if (send_handlers(FL_SHORTCUT)) return 1; -- cgit v1.2.3