Pressing a button

Hi All,

Appreciate your help on 2 items below.

(1) I have a button called ‘Convert’. When I press it, I like this button to change from one colour eg. From white to grey. After the finger is released, the colour changes back to white. This will let the user know they had indeed properly pressed the button. Appreciate if you could let me know how this could be done.

(2) I have seen apps that has a primary screen. On this screen there are lots of information and buttons. When the user presses a button on the primary screen, this whole screen slide to the left (or sometimes slide to the upper corner right) and disappear. In its place is a secondary screen that correspond to the button that was pressed. Can I ask (in general) how is this done? It appears the primary screen behaves as one object.

Kind Regards. [import]uid: 93204 topic_id: 18576 reply_id: 318576[/import]

1#:

[lua]local btn = display.newRect(0,0,50,50)

local function onTouch(self,event)

if event.phase == “began” then
self.alpha = 0.4
elseif event.phase == “ended” then
self.alpha = 1
end
end

btn.touch = onTouch
btn:addEventListener(“touch”, btn)[/lua]

as you can see, its very easy solution

2#: you can use this functions with Director module(you can find it at “share your code” tab above forum) or using Storyboard API from latest corona build [import]uid: 16142 topic_id: 18576 reply_id: 71334[/import]

Thank you!

For #1 - The alpha property did the trick for me. Everything works. But I did it without the .touch property. In fact, I would not find that property in the Corona references.

For #2 - OK, this will take some time for me to digest. But thanks for the info.

Kind Regards. [import]uid: 93204 topic_id: 18576 reply_id: 71392[/import]

Can text be assigned to this button below similar to a UI button?
example btn.text= “A” ???

How can one assigned text to this button? Thanks.
local btn = display.newRect(0,0,50,50)

local function onTouch(self,event)

if event.phase == “began” then
self.alpha = 0.4
elseif event.phase == “ended” then
self.alpha = 1
end
end

btn.touch = onTouch
btn:addEventListener(“touch”, btn) [import]uid: 104131 topic_id: 18576 reply_id: 71788[/import]