diff --git a/Userland/Libraries/LibGUI/SpinBox.cpp b/Userland/Libraries/LibGUI/SpinBox.cpp index 470a165f0e..95e379c7a0 100644 --- a/Userland/Libraries/LibGUI/SpinBox.cpp +++ b/Userland/Libraries/LibGUI/SpinBox.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. + * Copyright (c) 2022, Timothy Slater * * SPDX-License-Identifier: BSD-2-Clause */ @@ -24,10 +25,15 @@ SpinBox::SpinBox() return; auto value = m_editor->text().to_uint(); + if (!value.has_value() && m_editor->text().length() > 0) + m_editor->do_delete(); + }; + m_editor->on_focusout = [this] { + auto value = m_editor->text().to_int(); if (value.has_value()) set_value(value.value()); else - m_editor->set_text(String::number(m_value)); + set_value(min()); }; m_editor->on_up_pressed = [this] { set_value(m_value + 1);