summaryrefslogtreecommitdiff
path: root/test/handle_events.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-07-12 19:32:02 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-07-12 19:32:02 +0200
commit03913f32e0010076474d311758c388561eeac01e (patch)
tree0d9e44d4d0c3189686f4c5cd5fa3c9b48ec18a52 /test/handle_events.cxx
parent44840af076569ab6c692d7dcbcc70022d1d40087 (diff)
Display mouse button state in test/handle_events.cxx demo
See fltk.general, thread "Is handling simultaneous Left-click and Right-click drags supported?" from Jul 12, 2023 Status: FL_DRAG operation is terminated when one mouse button is released, even if more than one button is actually down. Subsequent mouse movement is reported as FL_MOVE rather than FL_DRAG, this is under investigation.
Diffstat (limited to 'test/handle_events.cxx')
-rw-r--r--test/handle_events.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/handle_events.cxx b/test/handle_events.cxx
index 30a17707a..b69f30540 100644
--- a/test/handle_events.cxx
+++ b/test/handle_events.cxx
@@ -1,7 +1,7 @@
//
// Event test program for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2021 by Bill Spitzak and others.
+// Copyright 1998-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -14,7 +14,7 @@
// https://www.fltk.org/bugs.php
//
-// compile standalone as: fltk-config --compile handle_events.cxx
+// Build: fltk-config --compile handle_events.cxx
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
@@ -62,13 +62,14 @@ public:
int app::handle(int ev) {
print_event(ev); // common for all events
int res = WINDOW_TYPE::handle(ev);
+ int buttons = Fl::event_buttons() >> 24; // bits: 1=left, 2=middle, 4=right button
switch (ev) {
case FL_PUSH:
- fprintf(stderr, ", button %d down", Fl::event_button());
+ fprintf(stderr, ", button %d down, buttons = 0x%x", Fl::event_button(), buttons);
res = 1;
break;
case FL_RELEASE:
- fprintf(stderr, ", button %d up", Fl::event_button());
+ fprintf(stderr, ", button %d up, buttons = 0x%x", Fl::event_button(), buttons);
res = 1;
break;
case FL_MOUSEWHEEL:
@@ -77,8 +78,11 @@ int app::handle(int ev) {
break;
case FL_ENTER:
case FL_LEAVE:
+ res = 1;
+ break;
case FL_MOVE:
case FL_DRAG:
+ fprintf(stderr, ", mouse buttons = 0x%x", buttons);
res = 1;
break;
case FL_KEYBOARD: