-- Simple immediate-mode buttons with (currently) just an onpress1 handler for -- the left button. -- -- Buttons can nest in principle, though I haven't actually used that yet. -- -- Don't rely on the order in which handlers are run. Within any widget, all -- applicable button handlers will run. If _any_ of them returns true, the -- event will continue to propagate elsewhere in the widget. -- draw button and queue up event handlers function button(state, name, params) if params.bg then if params.bg.r then -- old interface for compatibility love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a) else love.graphics.setColor(params.bg) end love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5) end if params.icon then params.icon(params) end table.insert(state.button_handlers, params) end function mouse_hover_on_any_button(state, x, y) for _,ev in ipairs(state.button_handlers) do if x>ev.x and xev.y and yev.x and xev.y and yev.x and xev.y and y