mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibGUI: Allow setting and clearing text in SpinBox
This commit is contained in:
parent
24046f9adf
commit
ec29d3abae
2 changed files with 9 additions and 0 deletions
|
@ -78,6 +78,9 @@ void SpinBox::set_value(int value, AllowCallback allow_callback)
|
||||||
|
|
||||||
void SpinBox::set_value_from_current_text()
|
void SpinBox::set_value_from_current_text()
|
||||||
{
|
{
|
||||||
|
if (m_editor->text().is_empty())
|
||||||
|
return;
|
||||||
|
|
||||||
auto value = m_editor->text().to_int();
|
auto value = m_editor->text().to_int();
|
||||||
if (value.has_value())
|
if (value.has_value())
|
||||||
set_value(value.value());
|
set_value(value.value());
|
||||||
|
@ -85,6 +88,11 @@ void SpinBox::set_value_from_current_text()
|
||||||
set_value(min());
|
set_value(min());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpinBox::set_text(StringView text, AllowCallback allow_callback)
|
||||||
|
{
|
||||||
|
m_editor->set_text(text, allow_callback);
|
||||||
|
}
|
||||||
|
|
||||||
void SpinBox::set_range(int min, int max, AllowCallback allow_callback)
|
void SpinBox::set_range(int min, int max, AllowCallback allow_callback)
|
||||||
{
|
{
|
||||||
VERIFY(min <= max);
|
VERIFY(min <= max);
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
int value() const { return m_value; }
|
int value() const { return m_value; }
|
||||||
void set_value(int, AllowCallback = AllowCallback::Yes);
|
void set_value(int, AllowCallback = AllowCallback::Yes);
|
||||||
void set_value_from_current_text();
|
void set_value_from_current_text();
|
||||||
|
void set_text(StringView, AllowCallback = AllowCallback::Yes);
|
||||||
|
|
||||||
int min() const { return m_min; }
|
int min() const { return m_min; }
|
||||||
int max() const { return m_max; }
|
int max() const { return m_max; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue