Enter and ESC keys in windows - best practices #17095
Replies: 1 comment
-
For the ones reading. I ended up with a solution 2.) and overriding all KeyDowns of the affected controls by subclassing. Similar as to this: I assume here the number of people expecting enter to confirm a dialog window is bigger than the number of people using keyboard only to navigate comboboxes/flip checkboxes. I see on the web (html) it behaves similar with the boxes. But there you less expect Enter to be used imho. In desktop applications enter is often used either to confirm/close a dialog window or to confirm an action/command inside a program. The user expects enter not to open a combobox if it's focused. kind regards Elco |
Beta Was this translation helpful? Give feedback.
-
Hi,
Does anyone have a best practice for Enter and ESC keys in dialog windows?
Ideally I would like Enter and ESC to behave as Apply->Close and Cancel->Close.
As simple as possible with just 2 buttons.
Somehow this is still very difficult to get working correctly.
I currently have 2 different ways:
1. Button.IsDefault and Button.IsCancel.
The problem with this is that is doesn't work if there is any control with focus. For example a combobox in the latest Avalonia release reacts to Enter more than usual it seems. And thus blocks the user from applying the form with Enter. Additionally sometimes it's not clearly visible which control has focus (i.e. checkbox). So the user doesn't get why it doesn't apply and close.
2. OnKeyUp of the window. Process Enter/ESC there.
This was my way around 1.). One downside is that you need to check for any multiline textboxes that have focus. Then cancel the close. But in the latest release if you have a control in focus (for example a checkbox that you just clicked) it will re-apply the checkbox first, and then close the window. Exactly the opposite of what you want as a user
Should you then handle every key event for every control in them form?
I've compared a lot with winforms over the years. Not saying any of the two is better. But there it seems the focus is less strictly bound to controls somehow. The problem doesnt' occur there.
Any tips/idea's are welcome!
kind regards
Elco
Beta Was this translation helpful? Give feedback.
All reactions