Adjusted ScrollContainer:handle to fix CCDrop bugs

This function has caused a lot of trouble in the past, especially when dealing with nested ScrollContainers.

Keep an eye on this. If you see any weird behavior when dealing with ScrollContainers this change may be the cause
This commit is contained in:
hbomb79 2017-05-07 19:56:07 +12:00
parent e18e241fe0
commit 5d374d6722

View file

@ -145,32 +145,35 @@ end
@return <boolean - propagate>
]]
function ScrollContainer:handle( eventObj )
local cache, isWithin = self.cache, eventObj.isWithin
local cache = self.cache
local cloneEv
if not self.super.super:handle( eventObj ) then return end
if self.projector and not self.mirrorProjector and not eventObj.projectorOrigin then
self.resolvedProjector:handleEvent( eventObj )
return
end
if eventObj.main == "MOUSE" then
eventObj.isWithin = eventObj:withinParent( self )
-- eventObj.isWithin = eventObj:withinParent( self )
if ( not cache.yScrollActive or ( eventObj.X - self.X + 1 ) ~= self.width ) and ( not cache.xScrollActive or ( eventObj.Y - self.Y + 1 ) ~= self.height ) then
cloneEv = eventObj:clone( self )
cloneEv.isWithin = cloneEv.isWithin and eventObj:withinParent( self ) or false
cloneEv.Y = cloneEv.Y + self.yScroll
cloneEv.X = cloneEv.X + self.xScroll
end
else cloneEv = eventObj end
if cloneEv then self:shipEvent( cloneEv ) end
local r = self.super.super:handle( eventObj )
-- local r = self.super.super:handle( eventObj )
eventObj.isWithin = isWithin
-- eventObj.isWithin = isWithin
if cloneEv and cloneEv.isWithin and ( self.consumeAll or cloneEv.handled ) then
eventObj.handled = true
end
return r == nil and true or r
-- return r
end
--[[