Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Float inputs don't allow typing a period after the number #17

Open
benediktwerner opened this issue Nov 12, 2022 · 1 comment
Open

Float inputs don't allow typing a period after the number #17

benediktwerner opened this issue Nov 12, 2022 · 1 comment

Comments

@benediktwerner
Copy link

When a float input has a current value like 7, it's impossible to type a . after it to eventually type something like 7.5.

The reason is that it parses the intermediate 7. as 7 and then immediately overrides the input value with that.

Once you know what the issue is, you can somewhat work around it by first typing 75 and then inserting the period but it's pretty confusing at first.

I guess one possible solution could be to not override the input if it's functionally identical, i.e. before setting the input value when the setting changed, parse the current input and check whether it's already the same value and if so, don't override it. This would also avoid the somewhat odd behavior of it automatically changing .7 to 0.7 and would also avoid it changing 7.0 to 7 if you want to type 7.05.

@benediktwerner
Copy link
Author

I guess after finishing writing ^ I realized this should be pretty easy to implement. Simply add

try
{
    var currVal = ParseMethod.Invoke(null, new object[] { valueInput.Text, CultureInfo.InvariantCulture });
    if (Value.Equals(currVal)) return;
}
catch { }

to the top of InteractiveNumber.RefreshUIForValue. And I guess probably move the part where it activates the game object above this.

I'd create a PR but this would conflict with #16 so just posting it here for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant