native alerts in button event handlers preventing proper button behaviour

Hi,

Not sure if this is a bug or a casualty of the fact that Corona has no control over the havoc native alerts can wreak.

When a native alert is called within a local function inside main.lua, which is referred to by my ui.newButton's onEvent parameter, the instant "overtaking" of the app's ability to govern itself by the native alert causes my ui.newButton object to misbehave... by this I mean that the "over" image is not made invisible--it remains after the alert is dismissed. And worse, the button somehow retains focus, so that a press anywhere on the screen causes the button to behave as if it was pressed.

Anyone else run into this?

I solved this battle between the native alert call and the will of my button's onEvent function by making my native alert call via a timer.performWithDelay(100,showAlert,1) line within said onEvent function. Now, that's kind of a kludge. But it worked.

Interestingly enough, (but it makes sense I guess) is that having a delay of 10ms wasn't enough. It is as if, the native alert fired while Corona was still processing the function and hadn't yet released control to its display update mechanism. So it set it the performWithDelay timer to 100 for comfort and it's fine so far.

Given that native alerts don't always play nice, perhaps it's best to use hand-rolled alerts instead.. i've seen one someone I think already in the Share Your Code section. Too bad tho... because I like the finesse of the native alerts.

I will still keep my native alerts in for now, with the 100ms delay so my function can complete and the button can behave as it should... but I'd be interested to know if there is a planned fix.

I should declare that I'm using the version of ui,lua that shipped with 2011.704 that I modded to use newImageRect. Also, my most system hogging alerts are the ones that have three lines of text in them. It's like it makes the OS chug to render the word-wrapped multiline alert.

Cheers!

Gary

views:2521 update:2012/2/13 9:11:28
corona forums © 2003-2011