Myra icon indicating copy to clipboard operation
Myra copied to clipboard

Bug: incorrect click behaviour

Open gamedevcb opened this issue 4 years ago • 2 comments

Myra has an incorrect click behaviour, as it triggers clicks OnTouchup(), regardless if the user has actually pressed down the mouse button inside the target button or not. This is unlike every other application that is out there, where clicks are only valid if both 'OnTouchDown' and 'OnTouchup' events are triggered from the same button.

A simple solution would be to check the 'IsPressed' bool before firing off the click event like: if(IsPressed) Click.Invoke(this); (of course, the isPressed would have to be reset to false after the click event has been fired)

https://github.com/rds1983/Myra/blob/e46221751586d160c59ca9a44754b9d8ca61b7ce/src/Myra/Graphics2D/UI/ButtonBase.cs#:~:text=public%20override%20void-,OnTouchUp(,-)

gamedevcb avatar Dec 22 '21 15:12 gamedevcb

I tend to disagree that every other application has different behavior. I've attached a small WPF sample(it's important to notice, that Myra is trying to mimic WPF behavior). Run it, press mouse button outside of the "Test" button, then move mouse inside the "Test" button and release. The "MouseUp" event will fire. WpfApp2.zip

rds1983 avatar Oct 27 '22 14:10 rds1983

After some more playing with WPF, I've noticed that Click event fires only if MouseDown/MouseUp events occured within the same button. Myra Button also has Click event. And a fix had been added so it would have the same behavior.

rds1983 avatar Oct 27 '22 15:10 rds1983