some finishing moves for the new event system

- focus order bug fixed
- added a new parameter for onChange() (its the value you would get with :getValue()
- small fix with drag events
- added paste events to textfields and input
- added a mouse event to input's (now you can change the text x position with mouse, like you can do in textfields
This commit is contained in:
Robert Jelic
2022-08-12 23:24:27 +02:00
parent f863b986c2
commit 373bbdc490
4 changed files with 105 additions and 9 deletions

View File

@@ -528,7 +528,27 @@ return function(name)
self:setVisualChanged()
return true
end
end;
end,
eventHandler = function(self, event, paste, p2, p3, p4)
if(base.eventHandler(self, event, paste, p2, p3, p4))then
if(event=="paste")then
if(self:isFocused())then
local w, h = self:getSize()
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
textX = textX + paste:len()
if (textX >= w + wIndex) then
wIndex = (textX+1)-w
end
local anchx, anchy = self:getAnchorPosition()
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
updateColors(self)
end
end
end
end,
draw = function(self)
if (base.draw(self)) then
@@ -577,6 +597,7 @@ return function(name)
self.parent:addEvent("mouse_drag", self)
self.parent:addEvent("key", self)
self.parent:addEvent("char", self)
self.parent:addEvent("other_event", self)
end,
}