Small bugfixes

This commit is contained in:
Robert Jelic
2025-02-26 10:19:46 +01:00
parent 0321e6617d
commit b2d273871d
4 changed files with 138 additions and 73 deletions

View File

@@ -102,6 +102,9 @@ VisualElement.registerEventCallback(VisualElement, "Enter", "mouse_enter", "mous
VisualElement.registerEventCallback(VisualElement, "LeEave", "mouse_leave", "mouse_move")
VisualElement.registerEventCallback(VisualElement, "Focus", "focus", "blur")
VisualElement.registerEventCallback(VisualElement, "Blur", "blur", "focus")
VisualElement.registerEventCallback(VisualElement, "Key", "key", "key_up")
VisualElement.registerEventCallback(VisualElement, "Char", "char")
VisualElement.registerEventCallback(VisualElement, "KeyUp", "key_up", "key")
local max, min = math.max, math.min
@@ -323,6 +326,24 @@ function VisualElement:calculatePosition()
return x, y
end
function VisualElement:key(key)
if(self.get("focused"))then
self:fireEvent("key", key)
end
end
function VisualElement:key_up(key)
if(self.get("focused"))then
self:fireEvent("key_up", key)
end
end
function VisualElement:char(char)
if(self.get("focused"))then
self:fireEvent("char", char)
end
end
--- Returns the absolute position of the element or the given coordinates.
--- @shortDescription Returns the absolute position of the element
---@param x? number x position