cancel
Showing results for 
Search instead for 
Did you mean: 

Perform actions on button release

GMeur
Senior

Hi,

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

Thanks.

2 REPLIES 2
Martin KJELDSEN
Chief III

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
Chief III

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.