Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to get id of tapped button.
Started by u3000 Oct 16 2018 06:42 PM

- - - - -
1 reply to this topic
button event click tap onevent

Best Answer XeduR @Spyric , 16 October 2018 - 07:38 PM

local function addItem(event)
     if("ended" == event.phase) then
         if event.target.id == "addBtn" then

         end
     end
end

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

u3000

[GLOBAL: userInfoPane.html]
u3000
  • Observer

  • 3 posts
  • Corona SDK

I need to know which button was tapped. I think id should be used - I don't know.
That's what I have:
 
local function addItem(event)
     if("ended" == event.phase) then
         --[[ IF ID == ... THEN --]]
     end
end


local addBtn = widget.newButton(
{
top = 170,
width = 70,
height = 70,
id = "addBtn",
defaultFile = "",
onEvent = addItem,
defaultFile = "add.png",
}
)


[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

  Best Answer

local function addItem(event)
     if("ended" == event.phase) then
         if event.target.id == "addBtn" then

         end
     end
end



[topic_controls]
[/topic_controls]