button .ui - Disable a button under a popup

Hi

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.

you could try
 bt01.IsVisible = false

while the pop up is shown, then when you revert back to the previous state just

  bt01.IsVisible = true

Dan

Hi Dan

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.

I'll post if I get to the bottom of this.

Thanks again.

This worked for me:

bt01.alpha = 0

and

bt01.alpha = 1 when you want it back

Hi noahm26

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.

Hi moosemedia,

Did you find solution of your problem? I have exactly the same problem...

I modified ui.lua like this to be able to disable the buttons:

1
2
3
local function newButtonHandler( self, event )
 
        if ( self.enabled ) then -- add this

Thanks :). Works great!

Hi Jochec & Ojnab

Thanks for the replies :

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

views:1623 update:2011/9/28 21:38:26
corona forums © 2003-2011