I have a button ( local bt01 = ui.newButton ) on a screen that I want to disable when it is under a popup, so I’ve set a test that prevents the function working when the popup is on screen.
However, the button ‘over’ state still shows if a user tries to press it. Does anyone know how to prevent this? I’ve disabled all the other listeners (removeEventListener), but I haven’t found a way to do this for the ui buttons.
Thanks for that. Yeah, it’s been one of the (many) things I’ve tried that doesn’t seem to work - actually it freezes the app and the lines that follow it don’t execute, so I’m not sure if it’s a referencing issue or not.
My guess is that if I set a flag inside the function, then test for this inside an Enterframe function, it’ll work fine. But I shouldn’t need to do this.
Thanks. It’s also something I tried with no luck. Actually (silly mistake) the functions were declared in the wrong order, so this is why the function was failing. (Doh)
So I can make the button invisible, but I was hoping to leave it on screen and disable the ‘over’ state somehow. i.e. I’ve disabled the button function, but it still highlights on user touch under the semi-transparent popup I have over it.
If all else fails I’ll just make the button invisible and perhaps replace it with a graphic that looks like the button. That’ll work.
Thanks for your response, much appreciated. [import]uid: 10814 topic_id: 11341 reply_id: 41230[/import]
I modified ui.lua like this to be able to disable the buttons:
[lua]local function newButtonHandler( self, event )
if ( self.enabled ) then – add this[/lua]
end the if statement right at the end of the “newButtonHandler” function:
[lua] return result
end – add this
end[/lua]
in “function newButton( params )” add
[lua]button.enabled = true – add this
return button[/lua]
right before the button is returned
now you can enable/disable your buttons with:
button.enabled = false ( or true )
Jochec - no, I didn’t. I eventually set a flag and tested for it within the button function, though also had to make the button disappear too, thereby hiding any highlights.
Ojnab - awesome, thanks. I’ll give that a whirl too. It sounds perfect.
Cheers [import]uid: 10814 topic_id: 11341 reply_id: 43749[/import]