Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions elements/input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ uie.add("button", {
bgNext = style.pressedBG
fgNext = style.pressedFG
borderNext = style.pressedBorder
elseif self.hovered then
elseif self.hovered or self.focused then
bgNext = style.hoveredBG
fgNext = style.hoveredFG
borderNext = style.hoveredBorder
Expand Down Expand Up @@ -125,6 +125,23 @@ uie.add("button", {
if self.enabled and cb and button == 1 then
cb(self, x, y, button)
end
end,

onKeyPress = function(self, key)
if self.enabled and (key == "space" or key == "return") then
self.pressed = true
end
end,

onKeyRelease = function(self, key)
local cb = self.cb
if self.enabled and (key == "space" or key == "return") then
self.pressed = false

if cb then
cb(self, self.screenX + self.width / 2, self.screenY + self.height / 2, 1)
end
end
end
})

Expand Down Expand Up @@ -1490,7 +1507,7 @@ uie.add("checkbox", {
end

local icon
local iconColor
local color
if value and self.activeIcon then
icon = self.activeIcon
color = self.style.activeIconColor
Expand Down Expand Up @@ -1525,6 +1542,24 @@ uie.add("checkbox", {
self:cb(self.value)
end
end
end,

onKeyPress = function(self, key)
if self.enabled and (key == "space" or key == "return") then
self.pressed = true
end
end,

onKeyRelease = function(self, key)
local cb = self.cb
if self.enabled and (key == "space" or key == "return") then
self.pressed = false
self:setValue(not self:getValue())

if cb then
cb(self, self.value)
end
end
end
})

Expand Down