Why do both MousePressed and MouseReleased trigger button events?

Started by jungletoe, 18 August 2013, 05:26:24

jungletoe

I find it a bit odd that it registers two clicks on buttons both when you release AND initially press the mouse button. Is there any reason for it/any way to stop it from doing this?

texus

v0.5 has the limitation that all widgets just send callbacks on all situations. In this case button can handle both mouse pressed and mouse clicked callbacks, so both will be send. This has been fixed in v0.6 where you specify which particular callback you want.

In your own code you could check if the callback.trigger equals tgui::Callback::mouseClick and otherwise ignore the callback.

Or if it becomes bothering to always check against the trigger then you could remove everything except the "m_MouseDown = true;" from the leftMousePressed function in Button.cpp on line 515.