how to make an invisible button?

the closest i’ve got is setting the alpha to 0.01 (set it to 0 and touch events dont work… presumably isVisible=false is triggered automatically)
http://developer.anscamobile.com/forum/2010/11/21/as2-port-ipod-style-scroll-wheel
[import]uid: 6645 topic_id: 3849 reply_id: 303849[/import]

Just check for touches inside a specific region on a background image that has been wired with a listener and execute a function when the touch is detected in that region.
eg:

[lua]local function checkForImageTouch ()

– if event.x and event.y are within 40 pixels of the invisible button center point then
–do something
–end

end

screenBackgroundGroup:addEventListener( “touch”, checkForImageTouch )[/lua]

You can even use that touch event to trigger a button that’s not visible:
[lua]myButton:dispatchEvent( event )[/lua] [import]uid: 1560 topic_id: 3849 reply_id: 11722[/import]

Use a transparent PNG. [import]uid: 11024 topic_id: 3849 reply_id: 11726[/import]

can 0.01 alpha actually be seen? my guess is it’s visibly clamped to 0 but the internal code doesn’t remove the display object [import]uid: 6645 topic_id: 3849 reply_id: 11730[/import]

local invisibleButton = display.newRect(0,0,width,height)  
invisibleButton:setFillColor(0,0,0,0)  
invisibleButton:addEventListener("touch", onTouch)  

[import]uid: 6459 topic_id: 3849 reply_id: 11817[/import]

thanks fmg

[import]uid: 6645 topic_id: 3849 reply_id: 11860[/import]

You just need to set the ‘isHitTestable’ flag to true.
By default, display objects that have an alpha of 0 cannot be interacted with.

-- invsible button  
local invsiblebutton = display.newRect( 0, 0, 60, 60 )  
invsiblebutton:setFillColor( 255,0,0 )  
invsiblebutton.x = 37  
invsiblebutton.y = 212  
invsiblebutton.alpha = 0  
invsiblebutton.isHitTestable = true  
invsiblebutton:addEventListener("touch", onTouch)  

I set them up like this so I can quickly turn their alpha to 0.5/0.0 when I am laying them out. [import]uid: 8444 topic_id: 3849 reply_id: 11842[/import]

thanks, .isHitTestable = true was a a good trick.
[import]uid: 11144 topic_id: 3849 reply_id: 19789[/import]