Button failing to fire a phase if covered by an alert

Hello,

I am having an issue with the button widget in my implementation for a long-press solution.

local buttonPressed local function startJobHandler(event) if (event.phase == "began") then buttonPressed = true timer.performWithDelay(2000, function() if (buttonPressed) then native.showAlert("Test", "Test test test test test.", {"Okay", "Retry"}) buttonPressed = false end end) elseif (event.phase == "ended" or event.phase == "cancelled") then buttonPressed = false end end

Once the alert is shown, the button becomes covered by the alert and the button fails to update the phase. Once the alert is closed, the button is stuck in the pressed state and requires an additional click (on the button or anywhere on the canvas) to update the state.

Is this something that I can handle on my end, or is this functionality working as intended?

I suppose all native functions overlap all the other functions and that is how it is intended to work.

Hi @Jglenn61091,

You might want to try force-dispatching an “ended” event to the button immediately before you show the alert. For example, assuming your button object is called “MY_BUTTON”:

[lua]

if (buttonPressed) then

    MY_BUTTON:dispatchEvent( { phase=“ended” } )

    native.showAlert(“Test”, “Test test test test test.”, {“Okay”, “Retry”})

    buttonPressed = false

end

[/lua]

Brent

I suppose all native functions overlap all the other functions and that is how it is intended to work.

Hi @Jglenn61091,

You might want to try force-dispatching an “ended” event to the button immediately before you show the alert. For example, assuming your button object is called “MY_BUTTON”:

[lua]

if (buttonPressed) then

    MY_BUTTON:dispatchEvent( { phase=“ended” } )

    native.showAlert(“Test”, “Test test test test test.”, {“Okay”, “Retry”})

    buttonPressed = false

end

[/lua]

Brent