# HG changeset patch # User Rik # Date 1587923300 25200 # Node ID 46a23dc62056d43f0e468956cc5f2ddb4ba81500 # Parent cba489221baba4197d0c9db16cf9042cf3aa3b13 Implement "gray" when uicontrol pushbuttons/togglebuttons are disabled (bug #57128) * BaseControl.cc (updatePalette): For pushbuttons & togglebuttons, add ":enabled" to beginning of StyleSheet specification so that custom colors are only applied when widget is active. * BaseControl.cc (init): Call blockSignals() if "Enable" property is "inactive" during setup of widget. Otherwise, call setEnabled() with value of "Enable" property. * BaseControl.cc (update): When updating "Enable" property, call blockSignals() if value is "inactive", otherwise call setEnabled(). diff -r cba489221bab -r 46a23dc62056 libgui/graphics/BaseControl.cc --- a/libgui/graphics/BaseControl.cc Sat Apr 25 19:44:57 2020 -0700 +++ b/libgui/graphics/BaseControl.cc Sun Apr 26 10:48:20 2020 -0700 @@ -84,8 +84,8 @@ { QColor bcol = Utils::fromRgb (props.get_backgroundcolor_rgb ()); QColor fcol = Utils::fromRgb (props.get_foregroundcolor_rgb ()); - QString qss = QString ("background: %1 none;\n" - "color: %2;") + QString qss = QString (":enabled { background: %1 none;\n" + "color: %2; }") .arg(bcol.name ()).arg (fcol.name ()); w->setStyleSheet(qss); return; @@ -124,7 +124,10 @@ octave::math::round (bb(2)), octave::math::round (bb(3))); w->setFont (Utils::computeFont (up, bb(3))); updatePalette (up, w); - w->setEnabled (! up.enable_is ("off")); + if (up.enable_is ("inactive")) + w->blockSignals (true); + else + w->setEnabled (up.enable_is ("on")); w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); w->setVisible (up.is_visible ()); m_keyPressHandlerDefined = ! up.get_keypressfcn ().isempty (); @@ -179,7 +182,13 @@ break; case uicontrol::properties::ID_ENABLE: - w->setEnabled (! up.enable_is ("off")); + if (up.enable_is ("inactive")) + w->blockSignals (true); + else + { + w->blockSignals (false); + w->setEnabled (! up.enable_is ("off")); + } break; case uicontrol::properties::ID_TOOLTIPSTRING: