Fix offset calculations
This commit is contained in:
parent
8232f116a5
commit
cb037bf811
@ -186,13 +186,10 @@ function Element:redraw()
|
||||
end
|
||||
|
||||
function Element:handleEvent(evt)
|
||||
if Event.isClickEvent(evt) and Event.containsClick(self, evt) then
|
||||
if self.onClick ~= nil then
|
||||
local x, y, source = Event.getClickParams(evt)
|
||||
return not not self.onClick(self, x, y, source)
|
||||
else
|
||||
return false
|
||||
end
|
||||
evt = Event.repositionEvent(evt, 1 - self:getX(), 1 - self:getY())
|
||||
if Event.isClickEvent(evt) and Event.containsClick(self, evt) and self.onClick ~= nil then
|
||||
local x, y, source = Event.getClickParams(evt)
|
||||
return not not self.onClick(self, x, y, source)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -127,6 +127,7 @@ function List:findById(id)
|
||||
end
|
||||
|
||||
function List:handleEvent(evt)
|
||||
evt = Event.repositionEvent(evt, 1 - self:getX(), 1 - self:getY())
|
||||
if Element.handleEvent(self, evt) then
|
||||
return true
|
||||
end
|
||||
@ -140,7 +141,7 @@ function List:handleEvent(evt)
|
||||
local wOffset = 0
|
||||
local hOffset = 0
|
||||
for _,child in ipairs(self.children) do
|
||||
if child:handleEvent({Event.repositionEvent(evt, -wOffset, -hOffset)}) then
|
||||
if child:handleEvent(evt) then
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -81,12 +81,14 @@ function Padding:findById(id)
|
||||
end
|
||||
|
||||
function Padding:handleEvent(evt)
|
||||
evt = Event.repositionEvent(evt, 1 - self:getX(), 1 - self:getY())
|
||||
|
||||
if Element.handleEvent(self, evt) then
|
||||
return true
|
||||
end
|
||||
|
||||
if Event.isClickEvent(evt) then
|
||||
return Event.containsClick(self, evt) and self.element:handleEvent({Event.repositionEvent(evt, -self:getPaddingLeft(), -self:getPaddingTop())})
|
||||
return Event.containsClick(self, evt) and self.element:handleEvent(evt)
|
||||
else
|
||||
return self.element:handleEvent(evt)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user