This commit is contained in:
parent
c1ba40ac70
commit
6e152a9f3f
|
@ -1,3 +1,5 @@
|
||||||
|
-- simple immediate-mode buttons
|
||||||
|
|
||||||
button_handlers = {}
|
button_handlers = {}
|
||||||
|
|
||||||
-- draw button and queue up event handlers
|
-- draw button and queue up event handlers
|
||||||
|
@ -9,10 +11,10 @@ function button(name, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- process button event handlers
|
-- 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
|
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 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
|
end
|
||||||
end
|
end
|
||||||
|
|
4
main.lua
4
main.lua
|
@ -129,8 +129,8 @@ function love.update(dt)
|
||||||
Drawing.update(dt)
|
Drawing.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x,y, button)
|
function love.mousepressed(x,y, mouse_button)
|
||||||
propagate_to_button_handlers(x,y, button)
|
propagate_to_button_handlers(x,y, mouse_button)
|
||||||
|
|
||||||
for line_index,line in ipairs(Lines) do
|
for line_index,line in ipairs(Lines) do
|
||||||
if line.mode == 'text' then
|
if line.mode == 'text' then
|
||||||
|
|
Loading…
Reference in New Issue