Monday, July 13, 2015

FMod - Mouse Drag Bugfix

While chatting on in the #KeenModding IRC channel yesterday, I found out about a little bug in Abiathar's UI. While selecting a region (e.g. with the Copier), using the arrow keys to pan the level resulted in the next mouse movement being counted as the second click of the selection even if the mouse button was not released. 

I looked around in the mouse movement handler (which is called to update the selection rectangle when the arrow keys are pressed, and also for normal mouse movement) and discovered that it assigns the "last state of the mouse buttons" variable even for the fake keyboard-induced mouse events. Since the fake event generator supplied blank values for everything, the button state variable got cleared, resulting in Abiathar thinking it got a new click when the mouse moved into a new tile with a button pressed.

I fixed that by making the mouse handler not set the button state variable if the mouse-move event isn't actually caused by a mouse movement. (I signal such events by setting the Delta field to 255, which can't happen naturally, if I remember correctly.)

No comments:

Post a Comment