Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for dots in number_input #267

Merged
merged 5 commits into from
Jul 23, 2024
Merged

Conversation

Ultraxime
Copy link
Contributor

Should fix #234

To fix it, I created a new widget, the TypedInput, it allows the user to write anything in a TextInput, but only send messages when it is a correct value, and then the message contain this value (not the string).

I then modify NumberInput to use this widget instead of a standard TextInput.

My code may not be the cleanest or respect all the guideline of the repo, so I'll be happy to edit it according to your liking.

…s valid for the given type)

Adding suport for dots in number input
…s valid for the given type) Adding suport for dots in number input
@Ultraxime
Copy link
Contributor Author

I'll fix the pipeline once I have feed back (to prevent doing such a small commit)

Copy link
Collaborator

@genusistimelord genusistimelord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but I'd need to test it first before pulling it in.

@Ultraxime
Copy link
Contributor Author

It could be interesting to make TypedInput able to have a different style when the entry is invalid, but I don't understand well enough this part of iced to do it

@genusistimelord
Copy link
Collaborator

Ok this is a decent update that does fix the issue. However, there was one issue I noticed that needs to be fixed before I can merge this. When using an u32 and setting the range from 0..250 I should be able to type 249, but I can not and can only type up to 248. Please fix this issue then I can merge it.

@Ultraxime
Copy link
Contributor Author

I think I know where it comes from (using self.min..self.max instead self.min..=self.max)
But I'm not sure if there is a real purpose to using two fields to store the min and the max, instead of using a field to store something implementing RangeBounds ?

@genusistimelord
Copy link
Collaborator

if Max is ..250 then it should go to 249 if max is ..=250 then it should go to 250. ATM I set it as ..250 so it should allow typing in 249 but I am only getting 248 as a max to type in.

@Ultraxime
Copy link
Contributor Author

I agree with what you are saying

My question was, wouldn't be better to store the bound using a type implementing RangeBounds.
Or is it a reason to using two fields ?

@genusistimelord
Copy link
Collaborator

the reason is to allow all Range's to work with this so the end user can dictate how they want their min and max's to be like.

@Ultraxime
Copy link
Contributor Author

Isn't what RangeBounds supposed to work ?

src/widgets/number_input.rs Outdated Show resolved Hide resolved
@genusistimelord
Copy link
Collaborator

you just need to resolve the format issue by running cargo fmt

@genusistimelord genusistimelord merged commit e8f03ed into iced-rs:main Jul 23, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

number_input, unable to type non-integer numbers.
2 participants