This commit is contained in:
Kartik K. Agaram 2022-05-17 23:18:56 -07:00
parent c1ba40ac70
commit 6e152a9f3f
2 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,5 @@
-- simple immediate-mode buttons
button_handlers = {}
-- draw button and queue up event handlers
@ -9,10 +11,10 @@ function button(name, params)
end
-- process button event handlers
function propagate_to_button_handlers(x, y, button)
function propagate_to_button_handlers(x, y, mouse_button)
for _,ev in ipairs(button_handlers) do
if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
if ev.onpress1 and button == 1 then ev.onpress1() end
if ev.onpress1 and mouse_button == 1 then ev.onpress1() end
end
end
end

View File

@ -129,8 +129,8 @@ function love.update(dt)
Drawing.update(dt)
end
function love.mousepressed(x,y, button)
propagate_to_button_handlers(x,y, button)
function love.mousepressed(x,y, mouse_button)
propagate_to_button_handlers(x,y, mouse_button)
for line_index,line in ipairs(Lines) do
if line.mode == 'text' then