Disable loq_ui_button [RESOLVED]

Currently I have an animation and while it is playing I want my buttons to be disabled. I have worked around this by having the buttons do nothing when they are pressed. But it would be nicer if they didn't go to their down state at all (when told not to). And then would enable again when the state of my game allows them to.

How would I go about making this work?

hi Eric,

I just updated loq_ui_button. Re d/l the spriteloq libs you'll see a function called setEnabled http://www.loqheart.com/spriteloq/apidocs/files/loq_ui_button-lua.html#SpriteButton.setEnabled

You can disable a button like so:

1
2
3
4
5
6
local loqbtn = require('loq_ui_button')
local btn = loqbutton.newButton { ... }
 
btn:setEnabled(false, 'down')  -- disables the button and then changes the visual state to down
 
btn:setEnabled(true, 'up') -- enables the button and sets the visual state to up

Wow. That worked like a charm! The buttons do not change states or send events! Exactly what I needed.

just to let you know, I tried to change the visual state, even though I don't need to.

1
layout.elements.btnForward:setEnabled(false, up)

Hey eric,

The state value must be a string. So the up needs quotes: 'up'. I'll update the docs to be more specific.

doh! my bad, thanks!

views:1673 update:2012/1/1 13:29:50
corona forums © 2003-2011