mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 18:37:35 +00:00
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
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
Add a link
Reference in a new issue