单击时,滚动视图中的按钮或图像如何工作? 但如果它们被移动(滚动)仍然保持滚动功能?
我读到了从事件处理函数返回true。 http://developer.anscamobile.com/content/events-and-listeners#Touch_Events
但这似乎仅适用于按钮顶部的按钮(点击/点击)。无论如何,在事件处理程序之后尝试返回true但没有帮助。
我可以检测按钮是否被移动,但不知道是否可以激活/传播以滚动。
这是一个更简单的代码版本
-- ScrollView listener
local function scrollListener( event )
local phase = event.phase
local direction = event.direction
return true
end
-- Create the widget
local scrollView = widget.newScrollView
{
...
listener = scrollListener
}
-- Create a image and insert it into the scroll view
local background = display.newImageRect( "assets/scrollimage.png", 768, 1024 )
-- Image/Button Listener
function blaBla( event )
if event.phase == "ended" then
-- do something on click
elseif event.phase == "moved" then
-- can't do anything to propagate this event to the scroll
end
return true
end
background:addEventListener( "touch", blaBla )
scrollView:insert( background )
答案 0 :(得分:0)
从触摸侦听器返回true会禁止将事件传播给其他侦听器。你不应该回归真实。
您也可以从触摸侦听器调用滚动侦听器。