From 03913f32e0010076474d311758c388561eeac01e Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 12 Jul 2023 19:32:02 +0200 Subject: 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. --- test/handle_events.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test') 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 #include @@ -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: -- cgit v1.2.3