summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/SpinBox.cpp
diff options
context:
space:
mode:
authorTimothy Slater <tslater2006@gmail.com>2022-08-30 20:59:58 -0500
committerSam Atkins <atkinssj@gmail.com>2022-09-01 17:47:49 +0100
commit5064b581eeed41f276c4e1951e19624c6f0e52c7 (patch)
tree4ac8225f377932d7a2735a4b69776f11d4149571 /Userland/Libraries/LibGUI/SpinBox.cpp
parente43e412fc86198a2dad600dc30a06618546f9d3a (diff)
downloadserenity-5064b581eeed41f276c4e1951e19624c6f0e52c7.zip
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.
Diffstat (limited to 'Userland/Libraries/LibGUI/SpinBox.cpp')
-rw-r--r--Userland/Libraries/LibGUI/SpinBox.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/SpinBox.cpp b/Userland/Libraries/LibGUI/SpinBox.cpp
index 95e379c7a0..48e2a1f95a 100644
--- a/Userland/Libraries/LibGUI/SpinBox.cpp
+++ b/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)