Skip to content

Commit d693141

Browse files
authored
Updated textfield
- fixed paste-events by removing an outdated if-statement
1 parent 73b4335 commit d693141

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Basalt/objects/Textfield.lua

+14-15
Original file line numberDiff line numberDiff line change
@@ -666,22 +666,21 @@ return function(name)
666666
end,
667667

668668
eventHandler = function(self, event, paste, p2, p3, p4)
669-
if(base.eventHandler(self, event, paste, p2, p3, p4))then
670-
if(event=="paste")then
671-
if(self:isFocused())then
672-
local w, h = self:getSize()
673-
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
674-
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
675-
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
676-
textX = textX + paste:len()
677-
if (textX >= w + wIndex) then
678-
wIndex = (textX+1)-w
679-
end
680-
local anchx, anchy = self:getAnchorPosition()
681-
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
682-
updateColors(self)
683-
self:updateDraw()
669+
base.eventHandler(self, event, paste, p2, p3, p4)
670+
if(event=="paste")then
671+
if(self:isFocused())then
672+
local w, h = self:getSize()
673+
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
674+
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
675+
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
676+
textX = textX + paste:len()
677+
if (textX >= w + wIndex) then
678+
wIndex = (textX+1)-w
684679
end
680+
local anchx, anchy = self:getAnchorPosition()
681+
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
682+
updateColors(self)
683+
self:updateDraw()
685684
end
686685
end
687686
end,

0 commit comments

Comments
 (0)