-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unfocus using escape key #3316
Comments
I think the scope of this may want to be smaller than indicated. |
I agree with @Jacalz that escape should unfocus everything, or at least be configurable by the app to do so. Having just added some keyboard controls to my app, including some typedKey shortcuts at the window.Canvas level, being able to unfocus with escape would be very useful. |
We prefer not adding lots of new APIs for all possible variations of a widget. It is already possible to use escape to unfocus your widget if you want to. In thinking about the initial request it was for better keyboard usability. At the root of it I am not sure that unsetting focus as a generic concept adds to usability because then you have lost keyboard context. Is it perhaps relating to getting out of multi-line text where the tab key is swallowed, and so you have to exit focus to keep moving with Tab/Shift-Tab @Jacalz? |
Well for one, it's not possible to "focus the main window", i.e. unfocus all individual widgets, using the tab key. So if there are key events bound to the window canvas itself, you currently have to use the mouse to click on something and reset the focus back to nil/the window. Maybe this isn't that much of a usability harm since a lot of other toolkits already don't have this behavior, so users may be used to having to use the mouse to unfocus everything. |
Sorry for my late reply. I agree with @dweymouth. Only unfocusing inside Entry would not work for applications that don't have any entry within the current view. |
My main use case for it is to add global shortcuts for switching between tabs (ctrl+tab and ctrl+num). If it only was possible to unfocus in an Entry, it would not be possible to use the shortcuts when within some tabs that do not contain Entry widgets. |
I played around with some other UIs (browsers, OS file manager, etc) and it does seem that using escape to unfocus everything is somewhat uncommon... but what would be needed for keyboard usability would be a way for key events to bubble up to the window if the focused widget didn't "do" anything with them. (e.g. in Firefox at least, pressing the arrow keys still scrolls the page if the focused UI element doesn't do anything with arrow keys). It seems like this would be a harder change to add to Fyne though, since it seems it would require focused widgets to indicate somehow whether each key event it receives while focused was actually handled, or if it should bubble up to the window. What are your thoughts @Jacalz ? |
As far as I am aware focus does not steal shortcuts... only other shorcuttable items do - so we really need to be clear on the definition here... is it a focus issue or a shortcuts issue. |
Before looking at how hard a solution is I think we have to really nail down the problem we are solving. After there is clarity there the right solution may become clear and then we aim to fix it irrespective of complexity... |
I think there are at least two things here:
|
The idea of bubbling up events has been discussed before but it hugely adds complexity to developer code and has been avoided. In the case of shortcuts it may indeed make sense to push "up" those that are not registered on the current widget. However the idea of keys not necessarily going to the input focused is less clear yes web browsers do it, but I don't think that is coded into the scroller I think the app / implementation handles it because it knows the domain. For example up in a web scroll is not the same as a list scroll or a table context. A generic solution as described isn't capable of that nuance, but coding it in the app is. This is why all our widgets are capable of being extended so you can add behaviours like this. |
Sorry for the late reply. This thread got stuck in the bottom of my email inbox. The problem that made me open this suggestion was indeed to allow tab changing commends to happen easier. However, I have though some more about this and also analysed more about how I use this feature in other apps. I see this a bit like an accessibility help and improvement for making keyboard navigation more ergonomic. Navigating using only the keyboard in large/complex user interfaces can be tricky. If you are somewhere in the middle (or just not at the top of the ui), it will take a lot of presses of tab to get to the desired item. Using escape to unfocus plus just a few tab presses, makes it very ergonomic and fast to get to the desired spot. I use this a lot in various applications on my system. Most often in the file browser but also in a few other places. |
Good point. |
Hmm. That's a good question. My opinion is that it would be best to do it at a driver level and have an opt-out like with tabs. Otherwise every custom widget will have to hook it up and that might lead to inconsistency for users expecting escape to unfocus. |
Is this still relevant? From testing around with some other UIs it seems that using escape to unfocus as a default behavior is actually fairly uncommon. I think it could possibly be handled in Entry as a special case since entry accepts tabs and therefore you can't move focus to the next widget without having escape to unfocus it. |
I still think it is very much relevant. At least for Entry and any other widgets that accepts the tab key and thus doesn't allow you to unfocus without using the mouse. I'd consider that an accessibility problem for anyone that has issues using the mouse. |
I would not be against adding it to all widgets though with support for disabling it on a widget label. Doing it on a driver label and adding something similar to the interface we have for accepting tab or not. |
Checklist
Is your feature request related to a problem?
We want to make the applications as usable as possible with just a keyboard. This has ergonomic and usability benefits and so on. However, right now we do not quite allow a widget to easily be unfocused without using a mouse. The next best thing with a keyboard is currently just to focus the next item.
Related to #1515
Is it possible to construct a solution with the existing API?
Yes, it should be possible. It might require something similar to the
AcceptTabs
interface that we have now for letting widgets get tab keys.Describe the solution you'd like to see.
I would like to have the focus manager handle unfocus of widgets when pressing the escape key. At the same time, I think it would be beneficial if it also closed dialogs (basically an “unfocus” of a dialog) when pressing the escape key as that would make applications even more usable.
As stated above, this might require an API to allow widgets to receive the escape key if they want to.
Cc @tilo
The text was updated successfully, but these errors were encountered: