change widget button default/over index after creation

I’m wondering, is it possible to change a button’s defaultindex/overindex for spritesheets after the button has been created?

i.e. create a button with defaultindex=1, overindex=2
calling some separate event would change defaultindex=3, overindex=4 on that same button,

without recreating the button from scratch?

[import]uid: 121569 topic_id: 34152 reply_id: 334152[/import]

I think in your button listener you can by using event.target.defaultIndex but from outside the listener you may be able to if each button has a unique name using buttonname.defaultIndex. But not sure never tried from outside the listener [import]uid: 7911 topic_id: 34152 reply_id: 135826[/import]

You can’t actually access the .defaultIndex and .overIndex of the widget.button objects or I wouldn’t be having a problem :frowning:

ex:

btn = widget.newButton{
width = 46, height = 40,
onEvent = somevent,
sheet = somesheet,
defaultIndex =1,
overIndex = 2
}

print(btn.defaultIndex)
print(btn.overIndex)

both return nil [import]uid: 121569 topic_id: 34152 reply_id: 135834[/import]

I think in your button listener you can by using event.target.defaultIndex but from outside the listener you may be able to if each button has a unique name using buttonname.defaultIndex. But not sure never tried from outside the listener [import]uid: 7911 topic_id: 34152 reply_id: 135826[/import]

You can’t actually access the .defaultIndex and .overIndex of the widget.button objects or I wouldn’t be having a problem :frowning:

ex:

btn = widget.newButton{
width = 46, height = 40,
onEvent = somevent,
sheet = somesheet,
defaultIndex =1,
overIndex = 2
}

print(btn.defaultIndex)
print(btn.overIndex)

both return nil [import]uid: 121569 topic_id: 34152 reply_id: 135834[/import]

Just use

event.target.default:setFillColor( 0, 255, 0, 255)   
  

inside the button listner to tint the image.

Haven´t tested other image settings on the button, but the tinting works like a charm.

Best,
Renato Bugge
Microingress Ltd [import]uid: 141323 topic_id: 34152 reply_id: 137716[/import]

Just use

event.target.default:setFillColor( 0, 255, 0, 255)   
  

inside the button listner to tint the image.

Haven´t tested other image settings on the button, but the tinting works like a charm.

Best,
Renato Bugge
Microingress Ltd [import]uid: 141323 topic_id: 34152 reply_id: 137716[/import]