Mouse off screen to enlarge button on click

The phase == “ended” in button onEvent handler contains code to enlarge the button clicked. But the code doesn’t work unless the mouse pointer goes off screen (and back) before clicking. On an ipad, there’s no mouse so the enlarge code never works. What focus or other thing can be done to fix this ?

local function HandleRightButtonEvent( event )
if (event.phase == “began”) then
bossTrigger = false
end
if (event.phase ==  “ended” ) then
rightButton:setEnabled( false )
wrongButton1:setEnabled( false )
wrongButton2:setEnabled( false )
wrongButton3:setEnabled( false )

– <code that enlarges the button>
event.target.width = event.target.width*1.2
event.target.height = event.target.height*1.2

– </code that enlarges the button>

ws_question = ws_question + 1
rightIcon.isVisible = true
bonus = true
ws_score = ws_score + ws_level
end

rightButton =  widget.newButton{
id = “rightButton”,
width = 96,
height = 96,
defaultFile = flagLoc … country[1],
label = “”,
onEvent = HandleRightButtonEvent
}
rightButton.x = display.contentWidth*positionArray[1]/5
rightButton.y = display.contentHeight*2/3

You can’t think of Corona’s buttons as having mouse actions. Instead, you have to think of them as touch events.  The “began” phase is similar to a “Mouse Down” event in that it starts the touch event.  Then the “ended” phase would be similar to “Mouse Up” and happens when you take your finger off the button.  Your code doesn’t trigger any actions until the touch phase has ended.

If you want your zoom to happen when the touch starts, you need to move your zoom code into the began phase. 

Rob

Moving your mouse after starting a press will generate several “moved” phases and potentially a “canceled” phase.

A runtime event handler was causing this strange behavior.

I removed the handler and all is well now.

Thank You to all that read and considered this !

You can’t think of Corona’s buttons as having mouse actions. Instead, you have to think of them as touch events.  The “began” phase is similar to a “Mouse Down” event in that it starts the touch event.  Then the “ended” phase would be similar to “Mouse Up” and happens when you take your finger off the button.  Your code doesn’t trigger any actions until the touch phase has ended.

If you want your zoom to happen when the touch starts, you need to move your zoom code into the began phase. 

Rob

Moving your mouse after starting a press will generate several “moved” phases and potentially a “canceled” phase.

A runtime event handler was causing this strange behavior.

I removed the handler and all is well now.

Thank You to all that read and considered this !