Improve multi-line selection (find bouding children)
This commit is contained in:
parent
7f2f70e1a6
commit
a33fcd19b4
|
@ -606,15 +606,40 @@ function addTabText(text, speaktype, tab, creatureName)
|
||||||
end
|
end
|
||||||
label.onDragMove = function(self, mousePos, mouseMoved)
|
label.onDragMove = function(self, mousePos, mouseMoved)
|
||||||
local parent = self:getParent()
|
local parent = self:getParent()
|
||||||
|
local parentRect = parent:getPaddingRect()
|
||||||
local selfIndex = parent:getChildIndex(self)
|
local selfIndex = parent:getChildIndex(self)
|
||||||
local child = parent:getChildByPos(mousePos)
|
local child = parent:getChildByPos(mousePos)
|
||||||
|
|
||||||
-- find out bounds children
|
-- find bouding children
|
||||||
if not child then
|
if not child then
|
||||||
if mousePos.y >= parent:getLastChild():getY() then
|
if mousePos.y < self:getY() then
|
||||||
child = parent:getLastChild()
|
for index = selfIndex - 1, 1, -1 do
|
||||||
elseif mousePos.y <= parent:getFirstChild():getY() then
|
local label = parent:getChildByIndex(index)
|
||||||
child = parent:getFirstChild()
|
if label:getY() + label:getHeight() > parentRect.y then
|
||||||
|
if (mousePos.y >= label:getY() and mousePos.y <= label:getY() + label:getHeight()) or index == 1 then
|
||||||
|
child = label
|
||||||
|
break
|
||||||
|
end
|
||||||
|
else
|
||||||
|
child = parent:getChildByIndex(index + 1)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif mousePos.y > self:getY() + self:getHeight() then
|
||||||
|
for index = selfIndex + 1, parent:getChildCount(), 1 do
|
||||||
|
local label = parent:getChildByIndex(index)
|
||||||
|
if label:getY() <= parentRect.y + parentRect.height then
|
||||||
|
if (mousePos.y >= label:getY() and mousePos.y <= label:getY() + label:getHeight()) or index == parent:getChildCount() then
|
||||||
|
child = label
|
||||||
|
break
|
||||||
|
end
|
||||||
|
else
|
||||||
|
child = parent:getChildByIndex(index - 1)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
child = self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue