LibGUI: SpinBox: update the displayed value when set_range() clamps it
Consider the following: upon instanciation of a GUI::SpinBox, its internal value and displayed value are both 0. When calling `set_min(1)` on it (same as `set_range(1, max())`), the internal value gets clamped to 1 correctly, but "0" is still displayed by the widget. The displayed value is now updated accordingly to the internal value when it gets clamped.
This commit is contained in:
parent
48cd26f12d
commit
951a429268
Notes:
sideshowbarker
2024-07-19 05:19:44 +09:00
Author: https://github.com/benit8 🔰 Commit: https://github.com/SerenityOS/serenity/commit/951a4292684 Pull-request: https://github.com/SerenityOS/serenity/pull/2657
1 changed files with 5 additions and 2 deletions
|
@ -80,8 +80,11 @@ void SpinBox::set_range(int min, int max)
|
|||
|
||||
int old_value = m_value;
|
||||
m_value = clamp(m_value, m_min, m_max);
|
||||
if (on_change && m_value != old_value)
|
||||
on_change(m_value);
|
||||
if (m_value != old_value) {
|
||||
m_editor->set_text(String::number(m_value));
|
||||
if (on_change)
|
||||
on_change(m_value);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue