diff --git a/birb/modules/menusystem/menus/widgets/base.lua b/birb/modules/menusystem/menus/widgets/base.lua index 3390a60..867d425 100644 --- a/birb/modules/menusystem/menus/widgets/base.lua +++ b/birb/modules/menusystem/menus/widgets/base.lua @@ -85,9 +85,16 @@ end -- DRAW WIDGETS -- Draw the widget -function BaseWidget:draw(x, y) +function BaseWidget:drawWidget(x, y, w, h) + if (self:haveFocus()) then + self:drawSelected(x, y, w, h) + else + self:draw(x, y, w, h) + end +end + +function BaseWidget:draw(x, y, w, h) if self.canvas.texture ~= nil then - utils.graphics.resetColor() love.graphics.draw(self.canvas.texture, x, y) end end @@ -106,6 +113,13 @@ function BaseWidget:update(dt) -- N/A end +-- FOCUS FUNCTIONS +-- Detect if the widget have focus + +function BaseWidget:haveFocus() + return (self.menu:haveFocus() and self.menu.widget:getSelected() == self.id) +end + -- ACTION FUNCTION -- Functions to handle actions and selection.