Normally when a ui button registers an event listener, the listener receives both a “press” and a “release” event. However, if you put the button in a scrollView, you only get a “press” event, which means you can’t detect when a user releases a button (which is the preferred way to detect a button press).
local ScrollView = require("scrollView")
local topBoundary = display.screenOriginY;
local bottomBoundary = display.screenOriginY;
local scrollView = ScrollView.new{ top=topBoundary, bottom=bottomBoundary };
local btnSelected = function( event )
print("phase: " .. event.phase) --this is always "press"
if (event.phase == "release") then
--this never happens, because you don't get the release phase
print("button id: ")
print(event.id)
end
end
local levelBtn = ui.newButton{
default = "image.png",
over = "image.png",
id = "1",
onEvent = btnSelected
}
scrollView:insert(levelBtn);
There has got to be a way around this right? The scrollView shouldn’t steal the release event from the button.
Also note that I can’t use “onRelease” in the levelBtn creation, because I need access to the button’s id. [import]uid: 52127 topic_id: 10235 reply_id: 310235[/import]