-
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
Tab between TextBoxes #606
Comments
I opened up this PR as a first draft of how this could work. Currently, this works as follows:
This works, but it doesn't seem like a really good solution. It requires people to manually manage which Widget will take focus. I think it would be better if the Ui could just handle that. Also, right now there are a bunch of warnings printed to stdout due to TextBoxes trying to uncapture when the next TextBox has already captured the keyboard. We could solve this just by removing the warning, but it seems like there's a cleaner solution for handling user input that would make all this simpler... |
In Window Forms this is solved by assigning each control a tab order index. |
Perhaps we could add a method to the This way we could just check for a tab input and then call Edit: We could take this further too by adding methods such as |
@mitchmindtree I like that idea! Definitely adding whatever method to I'm thinking, though, that the 'kind' of widget shouldn't really matter. I like the idea of either using the Widget Index, or else just defining the 'next' widget explicitly. Maybe something like:
Then, when the user hits tab, the TextBox can just call |
@bvssvni Scratch I like this idea, too. Just assigning a tab order sounds better. Then the widget graph could just keep track of all the tab orders and provide the next one on request. At first blush, I'd almost be tempted to use the widget index itself as the tab order. Maybe I'll start off using the widget index and then change it to a separate tab order once the proof of concept looks good. |
I finally got around to really working on this, and it's going to be a rather large pull request when it's done. I've struggled to find a clean way of implementing this without getting mired in refactoring how widgets capture/receive keyboard/mouse input. Currently, widgets such as the TextBox are responsible for calling So, there's two parts to the idea. One, is that whether a widget is capturing the keyboard/mouse should be solely determined by the The second piece would be to simplify how widgets receive input, from the mouse especially. Each widget is not only storing the state of whether it is capturing the keyboard/mouse, but it's also storing the state of the mouse itself. This also seems wrong. I've started adding semantic mouse events to the
The
This finally gets us to the point where we can just have two simple boolean fields on the It seems pretty weird to start by refactoring mouse input in order to handle tabbing between text boxes, but I really think that it's the right way to proceed. I had two different branches with working proof of concepts for tabbing between boxes, but they both seemed to be adding too much complexity to the whole capturing/uncapturing flow. Once I have the input refactoring finished, I'll put up a pull request for that before I actually finish the tabbing between text boxes functionality. All said, it should end up getting rid of a lot of code in some of the widgets for handling mouse input. Another side benefit of the |
@psFried Sounds nice! After making design changes, I often open up an issue and label it with "Information" to make it easy to find later. |
In the mean time, could we have a new event in TextBox conrod/conrod_core/src/widget/text_box.rs Line 184 in f448487
|
I think it would be nice to be able to move between text boxes just using the keyboard by hitting tab or enter. I've got something hacked together that works, but it's really ugly, and it seems like there must be a better way. Can anyone think of a non-hacky way to implement this?
Ideally, something like
Ui::force_focus_on(&mut self, idx: Into<Index>)
would be possible, whereidx
would refer to the widget to focus on. Something like,TextBox::steal_focus(mut self)
would also work. That is about what I have right now, but like I said, it doesn't feel like the cleanest implementation. Any ideas for a better approach?The text was updated successfully, but these errors were encountered: