Reputation: 4906
Is it possible to have a Corona button with label text and a icon? Something like this:
,===============,
[ Action • ]
`===============`
The bullet representing the icon, and Action
representing the label text.
Is this possible to build buttons like this using the Corona widget library?
Upvotes: 0
Views: 1007
Reputation: 321
I think you want to do this for example, on a rectangle button I want a arrow image with "NEXT" text which will look like "NEXT->"
There are two ways that you could do this:
Create the button background image with the -> on it, and use that for the Next button.
If you don't want to do that so you can keep the same background image for multiple buttons (ones with and without the ->), then create the widget button and position it. Put blank spaces in the text label for where you want the -> image to go, then calculate the position of the button and add a new image (not button) on top of it. Since I knew the buttons were never going to move and were always in the same position, it was fairly easy.
Upvotes: 1
Reputation: 62
If you want to use also text in your button you can use a class and make the button with image and text! :) And then you call the function and use this class ;)
as shown over, you can call the class, if your class name is buttonC then it's going to be buttonC:addEventListener("tap",methodOnTap)
Upvotes: 0
Reputation: 69
To achieve that you'll need to code it yourself. I personally like to do my buttons with an image and add an event listener to it, something like this:
local function methodOnTap( event )
print("Hey!! you tapped me!")
end
local buttonWithImage = display.newImage( "image.png")
buttonWithImage:addEventListener( "tap", methodOnTap )
this is a simple explanation on how to do a button with an image.
Upvotes: 1