瀏覽代碼

LibGUI: Disable increment/decrement buttons on SpinBox based on value

When the value for a SpinBox equals the max, disable the increment
button. Functionally, clicking the button doesn't do anything because
the set_value() clamps the value to min/max and updates the textbox.
However it is still nice to indicate to the user that they've reached
the max. Same goes for minimum value and the decrement button.
Timothy Slater 2 年之前
父節點
當前提交
5064b58
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Userland/Libraries/LibGUI/SpinBox.cpp

+ 4 - 0
Userland/Libraries/LibGUI/SpinBox.cpp

@@ -69,6 +69,10 @@ void SpinBox::set_value(int value, AllowCallback allow_callback)
     if (m_value == value)
         return;
     m_value = value;
+
+    m_increment_button->set_enabled(m_value < m_max);
+    m_decrement_button->set_enabled(m_value > m_min);
+
     m_editor->set_text(String::number(value));
     update();
     if (on_change && allow_callback == AllowCallback::Yes)