summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2006-10-29 13:22:28 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2006-10-29 13:22:28 +0000
commit7fffbf7deaae186c2e869c87e2d0fead17299efa (patch)
tree7305b0e8417c98b255f8af44efc92efb1a344e75 /src
parent8a64710a17df1c164d4bd6b3778b118de010b7f8 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx19
1 files changed, 15 insertions, 4 deletions
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;