fix scroll-to-caret in text widget, fixes #38

This commit is contained in:
airstruck
2016-02-05 00:37:55 -05:00
parent cf42d88148
commit 0b62db39ae

View File

@@ -25,17 +25,18 @@ local function updateHighlight (self)
end
local function scrollToCaret (self)
updateHighlight(self)
local x1, y1, w, h = self:getRectangle(true, true)
local x2, y2 = x1 + w, y1 + h
local oldX = self.endX or x1
if oldX <= x1 then
self.scrollX = self.scrollX - (x1 - oldX)
updateHighlight(self)
elseif oldX >= x2 then
self.scrollX = self.scrollX + (oldX - x2 + 1)
updateHighlight(self)
end
updateHighlight(self)
end
local function selectRange (self, startIndex, endIndex)