From 6322c783a39026553ceb700aed3cbe825d9064c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3hannes=20Gunnar=20=C3=9Eorsteinsson?= Date: Thu, 9 Jan 2020 13:44:23 +0000 Subject: [PATCH] Add apply method to SpinBox --- doc/classes/SpinBox.xml | 7 +++++++ scene/gui/spin_box.cpp | 5 +++++ scene/gui/spin_box.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml index be70e24234..2ae033f53a 100644 --- a/doc/classes/SpinBox.xml +++ b/doc/classes/SpinBox.xml @@ -26,6 +26,13 @@ Returns the [LineEdit] instance from this [SpinBox]. You can use it to access properties and methods of [LineEdit]. + + + + + Applies the current value of this [SpinBox]. + + diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index d21143739c..6827bf5507 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -246,6 +246,10 @@ bool SpinBox::is_editable() const { return line_edit->is_editable(); } +void SpinBox::apply() { + _text_entered(line_edit->get_text()); +} + void SpinBox::_bind_methods() { //ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed); @@ -259,6 +263,7 @@ void SpinBox::_bind_methods() { ClassDB::bind_method(D_METHOD("get_prefix"), &SpinBox::get_prefix); ClassDB::bind_method(D_METHOD("set_editable", "editable"), &SpinBox::set_editable); ClassDB::bind_method(D_METHOD("is_editable"), &SpinBox::is_editable); + ClassDB::bind_method(D_METHOD("apply"), &SpinBox::apply); ClassDB::bind_method(D_METHOD("_line_edit_focus_exit"), &SpinBox::_line_edit_focus_exit); ClassDB::bind_method(D_METHOD("get_line_edit"), &SpinBox::get_line_edit); ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input); diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 49dc6d950c..b2b65809dc 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -88,6 +88,8 @@ public: void set_prefix(const String &p_prefix); String get_prefix() const; + void apply(); + SpinBox(); };