Skip to content

Commit

Permalink
fix number inputs being reset when blank or invalid number
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Jan 22, 2025
1 parent c9dbc4b commit 6c6215b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion loader/src/loader/SettingNodeV3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class NumberSettingNodeV3 : public SettingValueNodeV3<S> {

m_input = TextInput::create(this->getButtonMenu()->getContentWidth() - 40, "Num");
m_input->setScale(.7f);
m_input->setCommonFilter(std::is_floating_point_v<typename S::ValueType> ? CommonFilter::Float : CommonFilter::Int);
m_input->setCallback([this, setting](auto const& str) {
this->setValue(numFromString<ValueType>(str).unwrapOr(setting->getDefaultValue()), m_input);
});
Expand Down Expand Up @@ -176,7 +177,7 @@ class NumberSettingNodeV3 : public SettingValueNodeV3<S> {
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));
}
Expand Down

0 comments on commit 6c6215b

Please sign in to comment.