summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/SpinBox.cpp8
-rw-r--r--Userland/Libraries/LibGUI/SpinBox.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/SpinBox.cpp b/Userland/Libraries/LibGUI/SpinBox.cpp
index 3886d4a594..9cf77e1446 100644
--- a/Userland/Libraries/LibGUI/SpinBox.cpp
+++ b/Userland/Libraries/LibGUI/SpinBox.cpp
@@ -78,6 +78,9 @@ void SpinBox::set_value(int value, AllowCallback allow_callback)
void SpinBox::set_value_from_current_text()
{
+ if (m_editor->text().is_empty())
+ return;
+
auto value = m_editor->text().to_int();
if (value.has_value())
set_value(value.value());
@@ -85,6 +88,11 @@ void SpinBox::set_value_from_current_text()
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)
{
VERIFY(min <= max);
diff --git a/Userland/Libraries/LibGUI/SpinBox.h b/Userland/Libraries/LibGUI/SpinBox.h
index 46098d79ec..c79ed42b35 100644
--- a/Userland/Libraries/LibGUI/SpinBox.h
+++ b/Userland/Libraries/LibGUI/SpinBox.h
@@ -19,6 +19,7 @@ public:
int value() const { return m_value; }
void set_value(int, AllowCallback = AllowCallback::Yes);
void set_value_from_current_text();
+ void set_text(StringView, AllowCallback = AllowCallback::Yes);
int min() const { return m_min; }
int max() const { return m_max; }