Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local cursor = {}

function cursor.hand()
local c = love.mouse.getSystemCursor("hand")
love.mouse.setCursor(c)
end

function cursor.default()
local c = love.mouse.getSystemCursor("arrow")
love.mouse.setCursor(c)
end

return cursor
28 changes: 27 additions & 1 deletion elements/basic.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local ui = require("ui.main")
local uie = require("ui.elements.main")
local uiu = require("ui.utils")

local cursor = require("ui.cursor")

-- Basic panel with children elements.
uie.add("panel", {
Expand Down Expand Up @@ -557,6 +557,32 @@ uie.add("image", {
end
end
end
end,
})

-- Clickable image.
uie.add("clickableImage", {
base = "image",
cb = nil,
interactive = 1,

init = function(self, cb, ...)
uie.image.init(self, ...)
self.cb = cb
end,

onClick = function(self)
if self.cb then
self.cb()
end
end,

onEnter = function(self, _)
cursor.hand()
end,

onLeave = function(self, _)
cursor.default()
end
})

Expand Down