From 34b5fe9e92a560d0507838c3dc1c6c3fd19648f9 Mon Sep 17 00:00:00 2001
From: Matthias Melcher <github@matthiasm.com>
Date: Wed, 11 Dec 2024 13:53:33 +0100
Subject: [PATCH] Fix drawing issue for checkbox buttons with bad box type
 (#1130)

---
 src/Fl_Button.cxx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx
index 308bb9bf3..5d40c37da 100644
--- a/src/Fl_Button.cxx
+++ b/src/Fl_Button.cxx
@@ -122,7 +122,8 @@ int Fl_Button::handle(int event) {
       if (newval != value_) {
         value_ = newval;
         set_changed();
-        redraw();
+        if (box() && (fl_box(box())==box())) redraw();
+        else redraw_label();
         if (when() & FL_WHEN_CHANGED) do_callback(FL_REASON_CHANGED);
       }
       return 1;
@@ -163,7 +164,10 @@ int Fl_Button::handle(int event) {
           int X = x() > 0 ? x() - 1 : 0;
           int Y = y() > 0 ? y() - 1 : 0;
           if (window()) window()->damage(FL_DAMAGE_ALL, X, Y, w() + 2, h() + 2);
-        } else redraw();
+        } else {
+          if (box() && (fl_box(box())==box())) redraw();
+          else redraw_label();
+        }
         return 1;
       } else return 0;
       /* NOTREACHED */
-- 
GitLab