Hi I am having a wpf application. I need to show some hot keys to user when they press alt key. The hotkeys must be displayed untill any keydown or click happens. this is similar to XamRibbon alt key I guess this is the same functionality in Excel using alt key.
I could implement by using InputBindings and KeyDown and KeyUp events but my business need is to let it display till user clicks somewhere else or some selection happens or some typing happens. which is the same in XamRibbon and Excel.
How do we achieve this kind of behavior??
Related
I'm using ReactJS and I have a lot of <button> in my code. I notice that I can use the Tab key to move over the button and there will be an outline on focused button like this:
But on this website which I'm trying to replicate, the buttons they use do not get Tab-focused on normal but just when we turn on the VoiceOver accessibility mode.
And the border of the Tab focus is also different.
I wonder how can we implement this in React?
Changing tabIndex to 0 or -1 doesn't work.
Thanks everyone!
Update
I ask because this leads to a problem:
If I use the UI Keyboard (UIKB) first and then try to type with the real keyboard keydown event. The tab focus would just stuck on the UIKB letter and return it twice.
This doesn't happen on the Wordle game because they just allow using tab focus when in accessibility mode.
tabIndex = -1 doesn't work because I want to allow the user use the tab focus just in a11y mode like Wordle, I don't want to totally disable it.
I want to set focus on a button while caret is present in textbox and user can still enter data to textbox. But when user presses enter key, button press will be simulated.
I am currently using a work around to solve this problem by handling onKeyDown event and checking for enter key. But problem is there is no clue for user to understand this as there is not blue border around the button that indicates focus on button.
Here is a example of what I want to implement (user can enter text in textbox while focus is on :
I have tried to search on google and StackOverflow but could not find any relevant result.
This is a fundamental Windows principle. It's not possible to have 2 controls (windows) focused at the same time.
So the focus should be inside the text box. But you can get the visual indication needed by setting the ok button as AcceptButton of the form (you might also want to set cancel button as CancelButton).
In the form constructor, load event or using designer:
this.AcceptButton = okButton;
There is no need to handle KeyDown event - as soon as the text box is not multiline, pressing Enter while the focus is inside it will generate ok button click. The same applies for the button set as CancelButton when you press ESC.
I'm using an autocomplete box and I'd like to remove the focus from the autocomplete box when I press enter on the keyboard.
I tried using the OnKeyDown method but it won't detect the enter key being pressed (it detects all other keys).
How can I detect the user pressing the enter key?
Thanks!
Fortunately I solved it! (I feel a bit stupid for asking the question now).
Turns out that although OnKeyDown works for most controls, in order to detect the enter key being pressed when using an autocomplete control, you need to use OnKeyUp.
I have wpf application in which I am using "ENTER" key as "TAB & Enter". If data are valid then move to next control.
My problem is that I want to raise TAB event programmatically. Please provide some code.....
You don't need to send a TAB key event to the application. Instead, use the MoveNext method to move focus to the next control
For a certain inputform, I'd like to make it possible to do input with the keyboard. I know how to read the keys through KeyPressed and KeyUp, but the problem is that when a control has got the focus and the user presses the Enter key, that control receives the a Click event. Is it possible to prevent that behaviour ? Or is it possible to know if a Click Event was fired by the mouse or by the keyboard ?
Does this help? From Microsoft Knowledge Base
Move the Button's code from the button.Click() to a button.MouseClick()
This would be easier if you could describe the situation and exact behaviour you want... :)
You can set:
Form.KeyPreview = True
This sends Key Events to the Form first, and then to the Control. This gives you the opportunity to catch Key Events on the form and 'cancel' them:
e.Handled = True
More info
Also make sure you haven't set the AcceptButton for the Form!
You can also listen for keyboard events and filter out keys.