Focus fix for list

This commit is contained in:
Robert Jelic
2025-04-03 18:03:06 +02:00
parent 477d83d7b3
commit 5ccd201be0
2 changed files with 43 additions and 1 deletions

View File

@@ -147,8 +147,8 @@ function List:mouse_click(button, x, y)
self:fireEvent("mouse_click", button, x, y)
self:fireEvent("select", adjustedIndex, item)
self:updateRender()
return true
end
return true
end
return false
end

42
src/elements/Switch.lua Normal file
View File

@@ -0,0 +1,42 @@
local elementManager = require("elementManager")
local VisualElement = elementManager.getElement("VisualElement")
---@cofnigDescription The Switch is a standard Switch element with click handling and state management.
--- The Switch is a standard Switch element with click handling and state management.
---@class Switch : VisualElement
local Switch = setmetatable({}, VisualElement)
Switch.__index = Switch
---@property checked boolean Whether switch is checked
Switch.defineProperty(Switch, "checked", {default = false, type = "boolean", canTriggerRender = true})
Switch.defineEvent(Switch, "mouse_click")
Switch.defineEvent(Switch, "mouse_up")
--- @shortDescription Creates a new Switch instance
--- @return table self The created instance
--- @private
function Switch.new()
local self = setmetatable({}, Switch):__init()
self.set("width", 2)
self.set("height", 1)
self.set("z", 5)
return self
end
--- @shortDescription Initializes the Switch instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @protected
function Switch:init(props, basalt)
VisualElement.init(self, props, basalt)
self.set("type", "Switch")
end
--- @shortDescription Renders the Switch
--- @protected
function Switch:render()
VisualElement.render(self)
end
return Switch