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.
This commit is contained in:
parent
e43e412fc8
commit
5064b581ee
Notes:
sideshowbarker
2024-07-17 07:34:56 +09:00
Author: https://github.com/tslater2006 Commit: https://github.com/SerenityOS/serenity/commit/5064b581ee Pull-request: https://github.com/SerenityOS/serenity/pull/15082 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/MacDue
1 changed files with 4 additions and 0 deletions
|
@ -69,6 +69,10 @@ void SpinBox::set_value(int value, AllowCallback allow_callback)
|
||||||
if (m_value == value)
|
if (m_value == value)
|
||||||
return;
|
return;
|
||||||
m_value = value;
|
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));
|
m_editor->set_text(String::number(value));
|
||||||
update();
|
update();
|
||||||
if (on_change && allow_callback == AllowCallback::Yes)
|
if (on_change && allow_callback == AllowCallback::Yes)
|
||||||
|
|
Loading…
Add table
Reference in a new issue