Skip to content

Regular expressions with textedit? #1200

Answered by emilk
saward asked this question in Q&A
Feb 3, 2022 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

There are two situations to consider:

  • Allowed character (e.g. only entering numbers)
  • Allowed formats (e.g. only allowing valid email addresses)

For the first case, I think we should add a filter to what characters TextEdit accepts, i.e. just a Fn(char) -> bool passed to one of the TextEdit builder functions. If the users tried to enter characters outside this filter, they won't be accepted.

For the second case, I think it is better to leave the validation to the egui user. How to respond to invalid input depends highly on the situation - sometimes you want to color the TextEdit red, or show an error text next to it.

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by saward
Comment options

You must be logged in to vote
1 reply
@emilk
Comment options

emilk Feb 4, 2022
Maintainer

Comment options

You must be logged in to vote
3 replies
@emilk
Comment options

emilk Feb 5, 2022
Maintainer

@saward
Comment options

@Mingun
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants