-
Notifications
You must be signed in to change notification settings - Fork 298
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
[WIP] Add support for "password" TextEdit and TextBox widgets #964
Conversation
Hey @daboross, thanks for the PR! I'm not sure how I feel about adding this into I think I'd like to think about our options a little longer before going ahead with this. I can definitely see this functionality being useful though! |
Abstraction sounds like a good idea, I'll see what I can pull out. Do you think, if we add this as a separate widget, we would want two ones to match TextEdit and TextBox, or just a TextBox equivalent? I'm not sure what the use case really is for a multi-line hidden text widget is, but it might want to be included for completeness? |
Any news on this? I would have a use case for this feature. |
Sorry! I've been a bit busy with other things, I definitely want to keep working on thin but my work with Conrad has been for a hobby project so far. Everything I've done for this PR is currently published, if you want to take a stab at making this a separate widget and abstracting out shared functionality, feel free to! I'll get back to this eventually but it may be a few weeks. |
@daboross Thanks for that quick response. I am not in a hurry about using this feature. I also just need it for a hobby project. I am busy enough myself right now, but if I find some time to tackle this, I will definitely ping you before I do, so no work here is wasted/replicated. Still even with a few weeks, you might be quicker ;) |
I feel like this could be made a lot simpler if Kind of like the note in // TODO: We should create a more specific `Event` type that:
// - Allows for mutating an existing `String` directly
// - Enumerates possible mutations (i.e. InsertChar, RemoveCharRange, etc).
// - Enumerates cursor movement and range selection. Having something (maybe an iterator wrapper over the events iterator?) that just turned a "mouse/key state" + "events" into "text changes" would be super helpful as an abstraction to work under both TextEdit, TextBox and a PasswordBox. The other thing needed would just be something generic to display some text + a selection from index1 to index2 in that text. It should be possible to make these abstraction - but I haven't gotten a working thing at all yet. If this was done, I think it could also mean TextBox could just handle the events itself, rather than having an inner TextEdit. |
0b9b71e
to
7bcb6f0
Compare
7bcb6f0
to
ee43384
Compare
ee43384
to
7afb4ce
Compare
This works, but may definitely want to be designed and implemented in a different way, as adding this in does seem a bit hacky.
7afb4ce
to
442ca51
Compare
Closing this, and opening a new PR for the event-based design. I feel like it's different enough from the ad-hoc password support implemented here to warrant a new PR. See: #1137. |
The way I've done it here technically works, but seems very hacky, and probably could be designed and written better.
There are a few places in TextEdit where
&text
is replaced with&replacement_string.as_ref().unwrap_or(&text)
, which is a bit bulky, but I'm not sure if there's a better way to do this while still having the ability to mutatetext
in the way this PR currently implements it.I've tested this with an example text box, and it seems to support dragging, selecting, deleting, and correctly treats the entire password as a single word for the sake of ctrl+left, ctrl+right and ctrl+backspace. I can look into adding some actual unit tests for this once the design is improved more.