input: remove focus on enter key. don't catch stoll/stodd exception.

This commit is contained in:
Andrea Blankenstijn 2021-07-13 13:30:19 +02:00
parent 03c6f51e16
commit 31370234df

View file

@ -82,7 +82,7 @@ namespace bwidgets::abstract
case SDLK_RETURN2: // what is return2 btw?
case SDLK_KP_ENTER:
value = value_from_string(input_text());
input_text(value_to_string(value));
focus(false);
break;
}
}
@ -186,17 +186,10 @@ namespace bwidgets::abstract
if constexpr(std::is_arithmetic_v<T>)
{
s = s.length() > 0 ? s : "0";
try
{
if constexpr(std::is_floating_point_v<T>)
v = (T)std::stold(s);
else if constexpr(std::is_integral_v<T>)
v = (T)std::stoll(s);
}
catch(std::exception&)
{
v = value;
}
if constexpr(std::is_floating_point_v<T>)
v = (T)std::stold(s);
else if constexpr(std::is_integral_v<T>)
v = (T)std::stoll(s);
}
else if constexpr(std::is_same_v<T, std::string> || std::convertible_to<std::string, T>)
v = s;