Is there a way to keep a button looking pressed?

Is there a way to have a button always look pressed after it’s pressed? I have a default file and an over file for a button but I am unsure how to set up the listener to change the button to lock on the pressed state.

You probably can’t do this with widget.newButton(), but there are ways to just use two images on top of each other. You should find this tutorial useful.

https://coronalabs.com/blog/2013/11/26/tutorial-techniques-for-swapping-images/

Basically have the one default showing, in your touch handler, hide or remove (if you’re done with it for good) the button and let the pressed looking button show.

Rob

This is the problem with the button widget.  It only has 2 states.   normal and roll over.  When it really need at least 4 states.   

normal, rollover, pressed, inactive.  

There are hanks to swap images around in a button group.   I don’t have time now but I will share later.  Do a search for swapping images.  there is a nice write up about it.  There is also a write up about adding a new image over the button widget after the fact.   

Can someone please just add 2 more states to the button widget so we don’t have to hack it!  

A button has two states - pressed and unpressed.  This functionality shouldn’t be changed as it is illogical.  If anything a new multi-state button could be added to the widgets library.

But as Rob has pointed out, and what most of us do, is just use images and use fills to switch states.  This allows much more customisation - like short-hold, long-hold, multi-tap, etc.

You probably can’t do this with widget.newButton(), but there are ways to just use two images on top of each other. You should find this tutorial useful.

https://coronalabs.com/blog/2013/11/26/tutorial-techniques-for-swapping-images/

Basically have the one default showing, in your touch handler, hide or remove (if you’re done with it for good) the button and let the pressed looking button show.

Rob

This is the problem with the button widget.  It only has 2 states.   normal and roll over.  When it really need at least 4 states.   

normal, rollover, pressed, inactive.  

There are hanks to swap images around in a button group.   I don’t have time now but I will share later.  Do a search for swapping images.  there is a nice write up about it.  There is also a write up about adding a new image over the button widget after the fact.   

Can someone please just add 2 more states to the button widget so we don’t have to hack it!  

A button has two states - pressed and unpressed.  This functionality shouldn’t be changed as it is illogical.  If anything a new multi-state button could be added to the widgets library.

But as Rob has pointed out, and what most of us do, is just use images and use fills to switch states.  This allows much more customisation - like short-hold, long-hold, multi-tap, etc.