Comments (6)
I tried to do this, when I reworked a few number_input things some time ago and there is one edge case I could not solve.
The problem becomes appending a dot, because the current value always has to be a valid number. Let say the current number is 10
, we can change it to .10
, which is valid (0.1
) and 1.0
, which is valid, but 10.
would not be valid, which means nothing happens. You can solve that by artificially appending a 0
to make it 10.0
and use that value, but we have a similar problem here. The string 10.0
is the same float, as the old 10
, so even though a on_changed is triggered and a message is emmited, the actual float does not change and thus will be rendered/formated as just "10" again, which means from a users perspective, the dot input was ignored. This is especially bad since this appending case is probably the most likely case for normal user input (writing a number left to right).
I only realy see two ways to make this work here.
- Ignore appending dots and just work with the inputting dots in the middle and at the beginning
- Force floats to always be formated with at least one decimal place (
10.0
), at which point inputting dots would becomes pointless
If either of them seem like a useable solution for the time being, I could add them, but I feel like they are both not great, which is why I gave up this initially
In theory there might be a 3. option involving decoupeling the text_input state&on_changed from the number_inputs, but that seems like a hard and error prone thing do do
from iced_aw.
yeah the issue here is ignore or not. I think not ignoring might be better since on the visual side we can make it appear as with just the dot but on the numeric side we can append a .0. This generally will be better for floating point numbers. as auto placing it on the string can mess up someones typing of a number if they have not finished yet. the only other way would be to make it focused and when enter is hit to make it unfocused then to do the .0 addition and such and not check the number till then. Downside to this is you need to handle the max and min by manually clamping the number after parsing it and then changing the string to what fits.
from iced_aw.
Related Issues (20)
- Tabs Closing icon HOT 2
- Compatible with iced 0.12.0? HOT 4
- Tabs causes overflow and/or overlap HOT 2
- Date Picker breaks with non-default font or font size HOT 9
- Mandatory copy trait makes it impossible to use custom message with additional parameters HOT 1
- feature request for menu - mac support HOT 1
- Can't use a PickList on a modal HOT 4
- index out of bounds in Tabs HOT 6
- Grid breaks Scrollable HOT 3
- fail to compile on the newest commit HOT 1
- A way to disable on scroll behavior in number_input HOT 1
- Card close_size extends down right when made larger HOT 2
- Grid is not scrolled together with scrollable content HOT 1
- [BUG] `tabs` panic if placed at application root HOT 3
- Numberinput requires mouse hover for keyboard input HOT 4
- Number input doesn't prevent overflow and underflow of the contained value
- Is there anyway to move add margins around a modal's overlay? HOT 3
- Dependabot update to 0.9.1 fails HOT 5
- font_loading example display error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iced_aw.