From 6c6215b3696b1e5d0352803a31481727651c4ef6 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Tue, 21 Jan 2025 23:42:39 -0300 Subject: [PATCH] fix number inputs being reset when blank or invalid number --- loader/src/loader/SettingNodeV3.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loader/src/loader/SettingNodeV3.hpp b/loader/src/loader/SettingNodeV3.hpp index b79ecbd02..b7abb4a67 100644 --- a/loader/src/loader/SettingNodeV3.hpp +++ b/loader/src/loader/SettingNodeV3.hpp @@ -113,6 +113,7 @@ class NumberSettingNodeV3 : public SettingValueNodeV3 { m_input = TextInput::create(this->getButtonMenu()->getContentWidth() - 40, "Num"); m_input->setScale(.7f); + m_input->setCommonFilter(std::is_floating_point_v ? CommonFilter::Float : CommonFilter::Int); m_input->setCallback([this, setting](auto const& str) { this->setValue(numFromString(str).unwrapOr(setting->getDefaultValue()), m_input); }); @@ -176,7 +177,7 @@ class NumberSettingNodeV3 : public SettingValueNodeV3 { m_input->setEnabled(enable); } - if (invoker != m_input) { + if (invoker != m_input && (invoker != nullptr || !m_input->getInputNode()->m_selected)) { // round to 5 decimal places to avoid floating point errors m_input->setString(numToString(round(this->getValue() * 100000.0) / 100000.0)); }