fixed handling global animation key event actions multiple times
authorHolger Schemel <info@artsoft.org>
Thu, 21 Mar 2019 22:36:36 +0000 (23:36 +0100)
committerHolger Schemel <info@artsoft.org>
Thu, 21 Mar 2019 22:36:36 +0000 (23:36 +0100)
When checking key events for triggering global animations, all keys
that are not handled as "click" events for the "any" animation event
were effectively treated like a "released button" event, which did
not have an effect if no mouse button was pressed at the same time.

However, when clicking on "clickable" global animations (those that
have a "click" animation event defined) with key event actions (that
will cause a simulated key press and release event), any key press
event that is not recognized as a "click" event will again be treated
like a "released button" event, causing the "button is pressed" state
in "HandleGlobalAnimClicks()" to be changed to "not pressed anymore",
so the still pressed mouse button will cause another "press event" in
"HandleGlobalAnimClicks()" right away, which will result in multiple
key events instead of one single key event. This may cause unexpected
and unwanted behaviour when handling global animation events.

This problem is fixed by only handling those key events for global
animations that will be handled as "click" events.

src/events.c

index 9966905b6286a496ee0a97868b2990105d6dc98a..11fd28f40035daab17fc49caf6e05a0995b8262c 100644 (file)
@@ -2145,9 +2145,12 @@ void HandleKey(Key key, int key_status)
     return;
   }
 
     return;
   }
 
-  if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space ||
-                                     key == KSYM_Return ||
-                                     key == KSYM_Escape), TRUE))
+  // some key events are handled like clicks for global animations
+  boolean click = (key == KSYM_space ||
+                  key == KSYM_Return ||
+                  key == KSYM_Escape);
+
+  if (click && HandleGlobalAnimClicks(-1, -1, MB_LEFTBUTTON, TRUE))
   {
     // do not handle this key event anymore
     if (key != KSYM_Escape)    // always allow ESC key to be handled
   {
     // do not handle this key event anymore
     if (key != KSYM_Escape)    // always allow ESC key to be handled