iced_aw icon indicating copy to clipboard operation
iced_aw copied to clipboard

Fix negative inputs and numpad handling by NumberInput

Open sterliakov opened this issue 6 months ago • 5 comments

Fixes #261. Fixes #333.

  • Allow lone minus sign in input, mapping it to 0 - the same way as for empty input.
  • Fix too eager handling of numpad keys - numpad keys are misdetected by core framework (see https://github.com/iced-rs/iced/pull/2278), this PR aligns their behaviour with TextInput.

sterliakov avatar Jun 07 '25 17:06 sterliakov

https://github.com/user-attachments/assets/478f494f-db33-424c-b9da-e79194a2c422

sterliakov avatar Jun 07 '25 17:06 sterliakov

Hm, the video renders fine on my end now. Perhaps a github glitch?

This works for FP numbers no worse than before. Naive implementation (just slapping an f64 as an underlying type) won't work anyway, so it should use some numeric wrapper that can be losslessly converted to/from decimal representation. But FP is difficult anyway - remember there are +0 and -0, NaNs, infinities...

sterliakov avatar Jun 07 '25 23:06 sterliakov

Given that "5." should parse as an f64, you'll likely be able to type floating numbers just fine. If you have a reference float wrapper code, we can check that too

sterliakov avatar Jun 08 '25 00:06 sterliakov

Looks good, I still need to check it.

It's not exactly what I was planning but should be enough while waiting to do something better

Ultraxime avatar Jun 11 '25 13:06 Ultraxime

ok once you approve it I can merge it.

genusistimelord avatar Jun 11 '25 13:06 genusistimelord