Skip to main content
GMeur
Associate III
February 21, 2019
Question

Perform actions on button release

  • February 21, 2019
  • 2 replies
  • 619 views

Hi,

If I want to perform a given action on button release and not on button press, what am I supposed to do ?

Thanks.

This topic has been closed for replies.

2 replies

Martin KJELDSEN
Principal III
February 22, 2019

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

Martin KJELDSEN
Principal III
February 22, 2019

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.