diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-01-18 10:40:37 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-01-18 10:40:37 +0000 |
| commit | 5411396ea63dda4f103ef733cc7d35f795ffa0c0 (patch) | |
| tree | 9a7ba736271312072163c990b8cd29206fc660bd | |
| parent | bc842ea528e7654db40f9c60571a48a6fd663804 (diff) | |
Fixed mousewheel event propagation (STR #1521)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5607 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | CHANGES | 1 | ||||
| -rw-r--r-- | FL/eventnames.h | 63 | ||||
| -rw-r--r-- | documentation/events.html | 5 | ||||
| -rw-r--r-- | src/Fl.cxx | 24 | ||||
| -rw-r--r-- | test/valuators.fl | 239 |
5 files changed, 142 insertions, 190 deletions
@@ -1,5 +1,6 @@ CHANGES IN FLTK 1.1.8 + - Fixed mousewheel event propagation (STR #1521) - Fixed drawing issues of a tile in a scroll (STR #1507) - Fixed dismissing buttons in menu bars (STR #1494) - Making a child group visible in a Fl_Tabs or Fl_Wizard diff --git a/FL/eventnames.h b/FL/eventnames.h new file mode 100644 index 000000000..213ad3ab1 --- /dev/null +++ b/FL/eventnames.h @@ -0,0 +1,63 @@ +// +// "$Id:$" +// +// Event names header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2007 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Thnaks to Greg Ercolano for this addition. + +#ifndef FL_EVENTNAMES_H +#define FL_EVENTNAMES_H +char *fl_eventnames[] = +{ + "FL_NO_EVENT", + "FL_PUSH", + "FL_RELEASE", + "FL_ENTER", + "FL_LEAVE", + "FL_DRAG", + "FL_FOCUS", + "FL_UNFOCUS", + "FL_KEYDOWN", + "FL_KEYUP", + "FL_CLOSE", + "FL_MOVE", + "FL_SHORTCUT", + "FL_DEACTIVATE", + "FL_ACTIVATE", + "FL_HIDE", + "FL_SHOW", + "FL_PASTE", + "FL_SELECTIONCLEAR", + "FL_MOUSEWHEEL", + "FL_DND_ENTER", + "FL_DND_DRAG", + "FL_DND_LEAVE", + "FL_DND_RELEASE", +}; +#endif /* FL_EVENTNAMES_H */ + +// +// End of "$Id:$". +//
\ No newline at end of file diff --git a/documentation/events.html b/documentation/events.html index fc33831f7..c4838e497 100644 --- a/documentation/events.html +++ b/documentation/events.html @@ -149,6 +149,11 @@ call the <a href="Fl.html#Fl.compose"><TT>Fl::compose()</TT></a> function to translate individual keystrokes into foreign characters. +<P><code>FL_KEYUP</code> events are sent to the widget that +currently has focus. This is not necessarily the same widget +that received the corresponding <code>FL_KEYDOWN</code> event +because focus may have changed between events. + <H3>FL_SHORTCUT</H3> <P>If the <A href="Fl.html#Fl.focus"><TT>Fl::focus()</TT></A> diff --git a/src/Fl.cxx b/src/Fl.cxx index 28f80225d..b6f0fe69b 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -796,6 +796,20 @@ int Fl::handle(int e, Fl_Window* window) fl_fix_focus(); return 1; + case FL_KEYUP: + // Send the key-up to the current focus. This is not + // always the same widget that received the corresponding + // FL_KEYBOARD event because focus may have changed. + // Sending the KEYUP to the right KEYDOWN is possible, but + // would require that we track the KEYDOWN for every possible + // key stroke (users may hold down multiple keys!) and then + // make sure that the widget still exists before sending + // a KEYUP there. I believe that the current solution is + // "close enough". + for (wi = grab() ? grab() : focus(); wi; wi = wi->parent()) + if (send(FL_KEYUP, wi, window)) return 1; + return 0; + case FL_KEYBOARD: #ifdef DEBUG printf("Fl::handle(e=%d, window=%p);\n", e, window); @@ -872,10 +886,16 @@ int Fl::handle(int e, Fl_Window* window) case FL_MOUSEWHEEL: fl_xfocus = window; // this should not happen! But maybe it does: - // Try sending it to the grab and then the window: - if (grab()) { + // Try sending it to the "grab" first + if (grab() && grab()!=modal() && grab()!=window) { if (send(FL_MOUSEWHEEL, grab(), window)) return 1; } + // Now try sending it to the "modal" window + if (modal()) { + send(FL_MOUSEWHEEL, modal(), window); + return 1; + } + // Finally try sending it to the window, the event occured in if (send(FL_MOUSEWHEEL, window, window)) return 1; default: break; diff --git a/test/valuators.fl b/test/valuators.fl index 668a462f6..1d9524458 100644 --- a/test/valuators.fl +++ b/test/valuators.fl @@ -1,198 +1,61 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0107 +version 1.0108 header_name {.h} code_name {.cxx} -Function {callback(Fl_Widget* o, void*)} {open private return_type void -} { - code {printf("%g \\r", ((Fl_Valuator*)o)->value()); -fflush(stdout);} {} +decl {\#include "eventnames.h" // Thanks Greg!} {} + +decl {\#include <FL/Fl_Window.H>} {public } +decl {\#include <cstdio>} {} + Function {} {open } { - Fl_Window {} { - label {Valuator classes, showing values for type()} open - xywh {479 151 580 510} type Double color 43 selection_color 43 - code0 {\#include <stdio.h>} visible + Fl_Window normal { + label Normal + private xywh {589 203 305 208} type Single hide + class Normal + } {} + Fl_Window modal { + label Modal selected + private xywh {685 85 100 100} type Single hide + class Modal + } {} + code {//modal->set_modal(); +normal->show(argc, argv);} {} +} + +class Normal {: {public Fl_Window} +} { + Function {Normal(int x, int y, int w, int h, const char* l = 0): Fl_Window(x,y,w,h,l)} {open + } {} + Function {handle(int e)} {open return_type int + } { + code {printf("Normal got an %s\\n", + fltk_eventnames[e]); +fflush(stdout); +Fl_Window::handle(e); +return 0;} {} + } +} + +class Modal {open : {public Fl_Window} +} { + Function {Modal(int x, int y, int w, int h, const char* l = 0): Fl_Window(x,y,w,h,l)} {open + } { + code {set_modal();} {} + } + Function {handle(int e)} {open return_type int } { - Fl_Box {} { - label Fl_Slider - xywh {10 10 280 210} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Slider {} { - label 0 - callback callback - tooltip {Vertical Slider} xywh {30 45 20 145} selection_color 1 labelsize 8 align 1 - } - Fl_Slider {} { - label FL_VERT_FILL_SLIDER - callback callback - xywh {70 55 20 145} type {Vert Fill} selection_color 1 labelsize 8 - } - Fl_Slider {} { - label FL_VERT_NICE_SLIDER - callback callback - xywh {105 45 20 145} type {Vert Knob} box FLAT_BOX color 10 selection_color 1 labelsize 8 align 1 - } - Fl_Slider {} { - label FL_HORIZONTAL - callback callback - xywh {140 80 130 20} type Horizontal selection_color 1 labelsize 8 - } - Fl_Slider {} { - label FL_HOR_FILL_SLIDER - callback callback - xywh {140 120 130 20} type {Horz Fill} selection_color 1 labelsize 8 - } - Fl_Slider {} { - label FL_HOR_NICE_SLIDER - callback callback - xywh {140 160 130 20} type {Horz Knob} box FLAT_BOX color 10 selection_color 1 labelsize 8 - } - Fl_Box {} { - label Fl_Value_Slider - xywh {10 230 280 210} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Value_Slider {} { - label 0 - callback callback - tooltip {Value Slider} xywh {30 260 30 145} selection_color 1 labelsize 8 align 1 - } - Fl_Value_Slider {} { - label FL_VERT_FILL_SLIDER - callback callback - xywh {70 275 30 140} type {Vert Fill} selection_color 1 labelsize 8 - } - Fl_Value_Slider {} { - label FL_VERT_NICE_SLIDER - callback callback - xywh {110 260 20 145} type {Vert Knob} box FLAT_BOX color 10 selection_color 1 labelsize 8 align 1 - } - Fl_Value_Slider {} { - label FL_HOR_SLIDER - callback callback - xywh {140 290 130 20} type Horizontal selection_color 1 labelsize 8 - } - Fl_Value_Slider {} { - label FL_HOR_FILL_SLIDER - callback callback - xywh {140 330 130 20} type {Horz Fill} selection_color 1 labelsize 8 - } - Fl_Value_Slider {} { - label FL_HOR_NICE_SLIDER - callback callback - xywh {140 370 130 20} type {Horz Knob} box FLAT_BOX color 10 selection_color 1 labelsize 8 - } - Fl_Box {} { - label Fl_Value_Input - xywh {10 450 135 50} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Value_Input {} { - label 0 - callback callback - tooltip {Value Input} xywh {30 470 105 25} labelsize 8 maximum 100 step 0.1 - } - Fl_Box {} { - label Fl_Value_Output - xywh {155 450 135 50} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Value_Output {} { - label 0 - callback callback - tooltip {Value Output} xywh {170 470 105 25} labelsize 8 maximum 100 step 0.1 - } - Fl_Box {} { - label { Fl_Scrollbar} - xywh {300 10 130 120} box ENGRAVED_BOX labelfont 1 align 21 - } - Fl_Scrollbar {} { - label FL_HORIZONTAL - callback callback - tooltip {Horizontal Scrollbar} xywh {305 65 95 20} type Horizontal labelsize 8 maximum 100 value 20 - } - Fl_Scrollbar {} { - label 0 - callback callback - tooltip {Vertical Scrollbar} xywh {400 20 20 105} labelsize 8 align 1 maximum 100 - } - Fl_Box {} { - label Fl_Adjuster - xywh {440 10 130 120} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Adjuster {} { - label {w()>h()} - callback callback - tooltip {Horizontal Adjuster} xywh {450 60 75 25} labelsize 8 - } - Fl_Adjuster {} { - label {w()<h()} - callback callback - tooltip {Vertical Adjuster} xywh {530 35 25 75} labelsize 8 - } - Fl_Box {} { - label Fl_Counter - xywh {300 140 130 120} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Counter {} { - label 0 - callback callback - tooltip {Standard Counter} xywh {310 175 110 25} labelsize 8 - } - Fl_Counter {} { - label FL_SIMPLE_COUNTER - callback callback - tooltip {Simple Counter} xywh {310 215 110 25} type Simple labelsize 8 - } - Fl_Box {} { - label Fl_Spinner - xywh {440 140 130 120} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Spinner {} { - label FL_INT_INPUT - xywh {465 176 80 24} labelsize 8 align 2 minimum -30 maximum 30 step 2 value 5 - } - Fl_Spinner {} { - label FL_FLOAT_INPUT - xywh {465 216 80 24} type Float labelsize 8 align 2 minimum 0 maximum 1 step 0.01 value 0.05 - } - Fl_Box {} { - label Fl_Dial - xywh {300 270 270 105} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Dial {} { - label 0 - callback callback - tooltip {Standard Dial} xywh {320 295 65 65} color 10 selection_color 1 labelsize 8 value 0.5 - code0 {o->angles(0,315);} - } - Fl_Dial {} { - label FL_LINE_DIAL - callback callback - tooltip {Line Dial} xywh {400 295 65 65} type Line color 10 selection_color 1 labelsize 8 value 0.5 - } - Fl_Dial {} { - label FL_FILL_DIAL - callback callback - tooltip {Fill Dial} xywh {480 295 65 65} type Fill color 10 selection_color 1 labelsize 8 value 1 - code0 {o->angles(0,360);} - } - Fl_Box {} { - label Fl_Roller - xywh {300 385 150 115} box ENGRAVED_BOX labelfont 1 align 17 - } - Fl_Roller {} { - label 0 - callback callback - tooltip {Vertical Roller} xywh {315 390 20 95} labelsize 8 - } - Fl_Roller {} { - label FL_HORIZONTAL - callback callback - tooltip {Horizontal Roller} xywh {345 430 90 20} type Horizontal labelsize 8 - } - Fl_Box {} { - label {Some widgets have color(FL_GREEN) and color2(FL_RED) to show the areas these effect.} selected - xywh {460 385 110 115} box BORDER_FRAME color 0 selection_color 0 labelsize 11 align 128 - } + code {printf(" Modal got an %s\\n", + fltk_eventnames[e]); +fflush(stdout); +/* Uncomment "return" to return subclass' handle() + * result. It reactivates Fl_Escape closing the + * window, but otherwise, doesn't seem to matter. + */ +//return +Fl_Window::handle(e); +return 1;} {} } } |
