Reputation: 11
Hello I am new in Corona SDK and I want to help me with my problem: Is it possible to use a text as button in Corona, and if yes can you show me how to do it? Thank you.
Upvotes: 0
Views: 720
Reputation: 8598
Each object in Corona can be assigned an event listener, which will respond to whatever event your subscribe it to. For a text to act as a button, you can do the following:
Create text object
local txtObj = display.newText('some text', 50, 50, native.systemFont, 20)
Create a method that will be executed upon text touch, eg.:
local function onClick(event)
print('I've been clicked')
end
Add event listener to your text object
txtObj:addEventListener('touch', onClick)
Now touching your text object will call onClick method, hence you're text will act like a button.
This is the simplest example, and there is much more to learn about events. See great documentation here and here.
Upvotes: 3