Skip to content
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

Hotkey control #2322

Merged
merged 11 commits into from
Jan 16, 2016
Merged

Hotkey control #2322

merged 11 commits into from
Jan 16, 2016

Conversation

thoemmi
Copy link
Collaborator

@thoemmi thoemmi commented Jan 14, 2016

This PR adds a HotKeyBox to MahApps.Metro with following features:

  • handles all hotkeys except Tab, Shift+Tab (used for navigation) and Back (clears the hotkey)
  • optionally modifier keys (Ctrl, Alt, Shift, or Win) are required
  • supports watermark
  • validation works
  • templating support
  • uses Win API GetKeyNameText to get a textual representation of the keys. No localization is required, as it only depends on the keyboard layout as configured in Windows. (I have a German keyboard, therefore you see STRG+UMSCHALT+POS1 in the screenshot; with an English layout it would say CTRL+SHIFT+HOME)
  • supports ControlsHelper.ContentCharacterCasing. The reason was that Windows is not consistent about what GetKeyNameText returns. E.g. on my machine with an English keyboard layout it returns normal-cased modifier keys, but upper-case function keys, which results in Ctrl+Shift+HOME. You may attach Controls:ControlsHelper.ContentCharacterCasing="Upper" to get consistent output.

image

The only purpose of HotKeyBox is to enable the user to enter a hotkey. Registering and handling hotkeys is out of its scope. I have added the control to the sample app and use NHotkey (NuGet) for the handling.

@bigworld12
Copy link
Contributor

exactly what I have been looking for, thanks!

@punker76
Copy link
Member

@thoemmi 👍

* added Text as readonly dependency property
* added support for Controls:ControlsHelper.ContentCharacterCasing
punker76 added a commit that referenced this pull request Jan 16, 2016
@punker76 punker76 merged commit 26b8abd into MahApps:develop Jan 16, 2016
@thoemmi thoemmi deleted the hotkey branch January 17, 2016 12:42
@moser96
Copy link

moser96 commented Jan 17, 2016

Create work 👍 .
I just included it in my project and it's working as expected ;)

@thoemmi
Copy link
Collaborator Author

thoemmi commented Jan 17, 2016

Thanks for your feedback, @moser96. Glad to hear that 😄

punker76 added a commit that referenced this pull request Jan 18, 2016
[RFC] Hotkey control (reverted from commit 26b8abd)
@thoemmi thoemmi changed the title [RFC] Hotkey control Hotkey control Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants