On the API reference page, under the “touch” event I see a few options:
event.id
event.name
event.phase
event.target
etc…
I am definitely using event.phase correctly, but I’m not sure what I’m doing different with the others.
local function runFunction(e)
print("id: "..e.id); --does not seem to return anything
print("target"..e.target); -- does not return anything
print("name: "..e.name); --returns "touch"
end
Runtime:addEventListener("touch", runFunction);
Should the “id” and “target” be displaying something?
Also, if I want to log the name of the element (or button name) that is touched, how would I do that?
For example, I may have 2 buttons that call the same function. I would love to know which button was pressed in the function.
[code]
local function runFunction(e)
print(“show which button I pressed, and any others I may introduce later”);
end
button1:addEventListener(“touch”, runFunction);
button2:addEventListener(“touch”, runFunction);
[/code] [import]uid: 154122 topic_id: 27389 reply_id: 327389[/import]
[import]uid: 52491 topic_id: 27389 reply_id: 111275[/import]