highlight another global
This commit is contained in:
parent
b544e8c357
commit
dc618a419c
|
@ -1,18 +1,18 @@
|
||||||
-- simple immediate-mode buttons
|
-- simple immediate-mode buttons
|
||||||
|
|
||||||
button_handlers = {}
|
Button_handlers = {}
|
||||||
|
|
||||||
-- draw button and queue up event handlers
|
-- draw button and queue up event handlers
|
||||||
function button(name, params)
|
function button(name, params)
|
||||||
love.graphics.setColor(params.color[1], params.color[2], params.color[3])
|
love.graphics.setColor(params.color[1], params.color[2], params.color[3])
|
||||||
love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
|
love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
|
||||||
if params.icon then params.icon(params.x, params.y) end
|
if params.icon then params.icon(params.x, params.y) end
|
||||||
table.insert(button_handlers, params)
|
table.insert(Button_handlers, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- process button event handlers
|
-- process button event handlers
|
||||||
function propagate_to_button_handlers(x, y, mouse_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 mouse_button == 1 then ev.onpress1() end
|
if ev.onpress1 and mouse_button == 1 then ev.onpress1() end
|
||||||
end
|
end
|
||||||
|
|
2
main.lua
2
main.lua
|
@ -95,7 +95,7 @@ function love.filedropped(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
button_handlers = {}
|
Button_handlers = {}
|
||||||
love.graphics.setColor(1, 1, 1)
|
love.graphics.setColor(1, 1, 1)
|
||||||
love.graphics.rectangle('fill', 0, 0, Screen_width-1, Screen_height-1)
|
love.graphics.rectangle('fill', 0, 0, Screen_width-1, Screen_height-1)
|
||||||
love.graphics.setColor(0, 0, 0)
|
love.graphics.setColor(0, 0, 0)
|
||||||
|
|
Loading…
Reference in New Issue