diff --git a/button.lua b/button.lua index df83704..099e966 100644 --- a/button.lua +++ b/button.lua @@ -9,6 +9,9 @@ -- draw button and queue up event handlers function button(State, name, params) + if State.button_handlers == nil then + State.button_handlers = {} + end if params.bg then love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a) love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5) @@ -19,6 +22,9 @@ end -- process button event handlers function mouse_press_consumed_by_any_button(State, x, y, mouse_button) + if State.button_handlers == nil then + return + end local button_pressed = false local consume_press = true for _,ev in ipairs(State.button_handlers) do