2019-02-21 02:44 AM
Hi,
If I want to perform a given action on button release and not on button press, what am I supposed to do ?
Thanks.
2019-02-22 05:27 AM
Hi @GMeur,
Pretty sure i posted a reply to a similar question somewhere, but can't find it right now.
If you take a look at AbstractButton::handleClickEvent() you'll see that it always fires on Released.
If you want to create a stateful widget (some graphics on down, other on up) but doesn't use the RELEASED action you'll have to create your own custom Button that can do this in handleClickEvent(). Feel free to copy code from the Button class.
Hope that helps,
Best regards,
Martin
2019-02-22 05:30 AM
Sorry, i was sure i read "I want to perform actions on button PRESSED". Performing actions on RELEASED is what the standard Button does =)
...
if (wasPressed && (event.getType() == ClickEvent::RELEASED) && action)
{
if (action->isValid())
{
action->execute(*this);
}
}
...
If you simply want to click something like a Box (which doesn't change state) choose the ClickListener mixin from the designer properties for that Box.