diff --git a/frontend/ui/widget/button.lua b/frontend/ui/widget/button.lua index 1a201b3f2..753259307 100644 --- a/frontend/ui/widget/button.lua +++ b/frontend/ui/widget/button.lua @@ -252,6 +252,9 @@ function Button:enable() if not self.enabled then if self.text then self.label_widget.fgcolor = Blitbuffer.COLOR_BLACK + if self.label_widget.update then -- using a TextBoxWidget + self.label_widget:update() -- needed to redraw with the new color + end else self.label_widget.dim = false end @@ -263,6 +266,9 @@ function Button:disable() if self.enabled then if self.text then self.label_widget.fgcolor = Blitbuffer.COLOR_DARK_GRAY + if self.label_widget.update then + self.label_widget:update() + end else self.label_widget.dim = true end @@ -289,6 +295,14 @@ function Button:enableDisable(enable) end end +function Button:paintTo(bb, x, y) + if self.enabled_func then + -- state may change because of outside factors, so check it on each painting + self:enableDisable(self.enabled_func()) + end + InputContainer.paintTo(self, bb, x, y) +end + function Button:hide() if self.icon and not self.hidden then self.frame.orig_background = self.frame.background diff --git a/frontend/ui/widget/buttontable.lua b/frontend/ui/widget/buttontable.lua index 90ab57ba7..a3dc803af 100644 --- a/frontend/ui/widget/buttontable.lua +++ b/frontend/ui/widget/buttontable.lua @@ -53,6 +53,7 @@ function ButtonTable:init() icon_height = btn_entry.icon_height, align = btn_entry.align, enabled = btn_entry.enabled, + enabled_func = btn_entry.enabled_func, callback = function() if self.show_parent and self.show_parent.movable then self.show_parent.movable:resetEventState()