From 28c1a3a839a5108f50e8f01661f9402daed54e39 Mon Sep 17 00:00:00 2001 From: Jacques PERON Date: Mon, 20 Jul 2026 10:17:31 +0200 Subject: [PATCH] Fix: restore default white background/radius fallback in Button:init Button:init() overrides KOReader's shared ui/widget/button module (module caching means this patches the global Button class, affecting every button in the app, not just kochess's own widgets). This copy dropped the fallback that sets background to COLOR_WHITE and computes border/radius when no custom background is provided, leaving self.frame.background nil for any default (uncolored) button created anywhere in KOReader after the chess board has been opened once. That nil background then crashes any button tap application-wide as soon as flash_ui highlighting runs, since Button:_doFeedbackHighlight calls self[1].background:invert() unconditionally. --- button.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/button.lua b/button.lua index a5d619e..0931fd0 100644 --- a/button.lua +++ b/button.lua @@ -160,12 +160,22 @@ function Button:init() self.label_widget, } end + local background_color, border_color, radius + if self.background then -- colored button + background_color = self.background + border_color = background_color -- without black border + radius = self.radius or Size.radius.button -- with rounded corners + else + background_color = Blitbuffer.COLOR_WHITE + radius = self.radius + end self.frame = FrameContainer:new{ margin = self.margin, show_parent = self.show_parent, bordersize = self.bordersize, - background = self.background, - radius = self.radius, + background = background_color, + color = border_color, + radius = radius, padding_top = self.padding_v, padding_bottom = self.padding_v, padding_left = self.padding_h,