Change text and default image of a button

Hello,

I would like to know that how to change a default image and the text of a ui button onPress or event?

For example, a green colored button with a text "Button 1" is present and when I click the button, the color or image of the button will change and the text on the button will also change to "Button 2".

Any replies regarding the matter will be helpful.

Thank you.

The button image you select when creating it so you'd want to remove and recreate the button.

The text I believe can be changed by using buttonName.text = "whatever", etc. although I'm a little rusty on this kind of thing; can you let me know if that works for you please?

Peach :)

Hi Peach,

Thanks for your reply but that did not work.

I can however change the image by using over event but again how would I deactivate the onRelease function so that the button is pressed and the new image stays after clicking?

Thank you,

Regards,

Aakash.

Hey again Aakash,

OK, just looked into it, this is the code you would use for changing the button's text;

button:setText("test")

For the image you can't simply stop it from changing back to the normal image on release, you'd just make it look like it - for example removing the button and adding a new image, (just down "onPressed" image) in its place.

Peach :)

views:1775 update:2012/2/8 8:46:10
corona forums © 2003-2011