mirror of https://github.com/fltk/fltk
Keep sending FL_DRAG until all mouse buttons are released
The old version would send FL_MOVE events after dragging with more than one mouse buttons pressed, as soon as the first button was released. The new version sends FL_DRAG until the last mouse button is released and then FL_MOVE, as usual. This change affects dragging only if more than one mouse button is pushed and held while dragging. The order of pushing and releasing mouse buttons does not affect the behavior.
This commit is contained in:
parent
f8d0b591ab
commit
1259275316
39
src/Fl.cxx
39
src/Fl.cxx
|
@ -1359,7 +1359,7 @@ int Fl::handle_(int e, Fl_Window* window)
|
|||
ret = (wi && send_event(e, wi, window));
|
||||
if (pbm != belowmouse()) {
|
||||
#ifdef DEBUG
|
||||
printf("Fl::handle(e=%d, window=%p);\n", e, window);
|
||||
printf("Fl::handle(e=%d, window=%p) -- Fl_Tooltip::enter(%p);\n", e, window, belowmouse());
|
||||
#endif // DEBUG
|
||||
Fl_Tooltip::enter(belowmouse());
|
||||
}
|
||||
|
@ -1367,19 +1367,44 @@ int Fl::handle_(int e, Fl_Window* window)
|
|||
}
|
||||
|
||||
case FL_RELEASE: {
|
||||
// printf("FL_RELEASE: window=%p, pushed() = %p, grab() = %p, modal() = %p\n",
|
||||
// window, pushed(), grab(), modal());
|
||||
|
||||
// Mouse drag release mode - Jul 14, 2023, Albrecht-S (WIP):
|
||||
// 0 = old: *first* mouse button release ("up") turns drag mode off
|
||||
// 1 = new: *last* mouse button release ("up") turns drag mode off
|
||||
// The latter enables dragging with two or more pressed mouse buttons
|
||||
// and to continue dragging (i.e. sending FL_DRAG) until the *last*
|
||||
// mouse button is released.
|
||||
// See fltk.general, thread started on Jul 12, 2023
|
||||
// "Is handling simultaneous Left-click and Right-click drags supported?"
|
||||
|
||||
static const int drag_release = 1; // should be 1 => new behavior since Jul 2023
|
||||
|
||||
// Implementation notes:
|
||||
// (1) Mode 1 (new): only if *all* mouse buttons have been released, the
|
||||
// Fl::pushed_ widget is reset to 0 (NULL) so subsequent system "move"
|
||||
// events are no longer sent as FL_DRAG events.
|
||||
// (2) Mode 0 (old): Fl::pushed_ was reset on the *first* mouse button release.
|
||||
// (3) The constant 'drag_release' should be removed once the new mode has been
|
||||
// confirmed to work correctly and no side effects have been observed.
|
||||
// Hint: remove condition "!drag_release || " twice (below).
|
||||
|
||||
// printf("FL_RELEASE: window=%p, pushed() = %p, grab() = %p, modal() = %p, drag_release = %d, buttons = 0x%x\n",
|
||||
// window, pushed(), grab(), modal(), drag_release, Fl::event_buttons()>>24);
|
||||
|
||||
if (grab()) {
|
||||
wi = grab();
|
||||
pushed_ = 0; // must be zero before callback is done!
|
||||
if (!drag_release || !Fl::event_buttons())
|
||||
pushed_ = 0; // must be zero before callback is done!
|
||||
} else if (pushed()) {
|
||||
wi = pushed();
|
||||
pushed_ = 0; // must be zero before callback is done!
|
||||
} else if (modal() && wi != modal()) return 0;
|
||||
if (!drag_release || !Fl::event_buttons())
|
||||
pushed_ = 0; // must be zero before callback is done!
|
||||
} else if (modal() && wi != modal())
|
||||
return 0;
|
||||
int r = send_event(e, wi, window);
|
||||
fl_fix_focus();
|
||||
return r;}
|
||||
return r;
|
||||
}
|
||||
|
||||
case FL_UNFOCUS:
|
||||
window = 0;
|
||||
|
|
Loading…
Reference in New Issue