Button event simulation

I wrote the code below and let me know how to simulate the pressure of bottone1? Sorry for my horrible English.

local function onKeyEvent( event )

if (event.keyName == “menu”) and (event.phase == “down”) then

     How to simulate the button 1 is pressed?

end

local button1Press = function( event )

    print (“Press button1”)

end

button3 = widget.newButton

{

defaultFile = “res/buttonRed.png”,

overFile = “res/buttonRedOver.png”,

labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 0, 0.5 } },

label = “RESET”,

emboss = true,

onPress = button1Press,

}

button1.x = display.contentWidth / 2; button1.y = 180

Runtime:addEventListener( “key”, onKeyEvent) 

based on this And if you have a problem - then it’s button3 -----[3]----- as your widget but later you use the number 1.

Also the onkeyevent normally relates to device buttons - home, volume not any display object buttons.

T.

I you want to simulate a system button press (or any other event) you would create an apropriate event table and call dispatch event.

local event = {name = “key”, keyName = “menu”, phase = “down”}

Runtime:dispatchEvent(event)

Maybe I missed something but that’s the general idea.

based on this And if you have a problem - then it’s button3 -----[3]----- as your widget but later you use the number 1.

Also the onkeyevent normally relates to device buttons - home, volume not any display object buttons.

T.

I you want to simulate a system button press (or any other event) you would create an apropriate event table and call dispatch event.

local event = {name = “key”, keyName = “menu”, phase = “down”}

Runtime:dispatchEvent(event)

Maybe I missed something but that’s the general idea.