mirror of
https://github.com/godotengine/godot.git
synced 2025-02-01 14:45:22 +00:00
Calculate the SpinBox value using the Expression class
This closes #31780.
This commit is contained in:
parent
a5e0aa32d9
commit
86a31e9e38
@ -29,6 +29,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "spin_box.h"
|
#include "spin_box.h"
|
||||||
|
#include "core/math/expression.h"
|
||||||
#include "core/os/input.h"
|
#include "core/os/input.h"
|
||||||
|
|
||||||
Size2 SpinBox::get_minimum_size() const {
|
Size2 SpinBox::get_minimum_size() const {
|
||||||
@ -50,15 +51,18 @@ void SpinBox::_value_changed(double) {
|
|||||||
|
|
||||||
void SpinBox::_text_entered(const String &p_string) {
|
void SpinBox::_text_entered(const String &p_string) {
|
||||||
|
|
||||||
/*
|
Ref<Expression> expr;
|
||||||
if (!p_string.is_numeric())
|
expr.instance();
|
||||||
|
Error err = expr->parse(p_string);
|
||||||
|
if (err != OK) {
|
||||||
return;
|
return;
|
||||||
*/
|
}
|
||||||
String value = p_string;
|
|
||||||
if (prefix != "" && p_string.begins_with(prefix))
|
Variant value = expr->execute(Array(), NULL, false);
|
||||||
value = p_string.substr(prefix.length(), p_string.length() - prefix.length());
|
if (value.get_type() != Variant::NIL) {
|
||||||
set_value(value.to_double());
|
set_value(value);
|
||||||
_value_changed(0);
|
_value_changed(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LineEdit *SpinBox::get_line_edit() {
|
LineEdit *SpinBox::get_line_edit() {
|
||||||
|
Loading…
Reference in New Issue
Block a user