Reputation: 591
I am working on a C# WinForm application in Visual Studio 2008. I have added keyboard shortcuts to some of the buttons, which triggers a button click (CTRL + R, CTRL B and so on...), by overriding ProcessCmdKey.
When the user press and hold the CTRL key I want to show a hint, tooltip or something next to the button with the shortcut text ("CTRL + R") so the user can see which buttons that has a shortcut and what the combination is.
Does anyone have any other suggestion on how to solve this issue?
Upvotes: 1
Views: 1714
Reputation: 591
I solved this by creating a WPF control that looks similar to a standard tooltip (small box with a label). I then did an override on ProcessCmdKey and OnKeyUp on my form to listen to CTRL key down and key up.
When the user presses and holds down the CTRL key I loop through all my controls that has a shortcut and creates a WPF control on top of that control. For each WPF control I set the corresponding shortcut text. When the CTRL key is released I remove all WPF controls in OnKeyUp.
Upvotes: 0
Reputation: 48568
That thing is possible with &
in Caption. When user presses Alt
Key, character after &
in caption of button become Underlined and when user presses that underline character key. click event of button gets fired.
(Sorry forgotting term for this).
Upvotes: 1