Is it possible to have keyboard shourtcuts for Application Button in WPF Ribbon control?
There are 2 ways:
Use the KeyTip property on each level of your ribbon. For example, you need to assign a KeyTip of "H" on your "Home" tab and then "A" on the "Add" button in that tab. If you don't assign KeyTips to the higher levels, you can't access the lower levels. Also, you can assign keytips to the application menu.
If you are using something like the MVVM pattern and are binding to your custom commands, you can make direct "classic" style keyboard shortcuts by binding an KeyBinding to a command in Window.InputBindings.
<Window.InputBindings>
<KeyBinding Command="{Binding OpenWindow}"
CommandParameter="About"
Gesture="F1"/>
</Window.InputBindings>
Ctrl+F and such also work.
Related
I am looking for a way to allow a user to complete a Dialog entry using keyboard shortcuts. Is this possible?
Other questions have discussed assigning shortcuts to the options in an AppleScript dialog box, but not to the "Continue"/"Okay" etc. button.
The main difficulty is that I'm using a multi-line text entry form, so the Enter button simply creates a new line, instead of targeting the default button as it would conventionally. I'm hoping cmdenter can be assigned to the default button instead.
The line of script defining the dialog in question is:
set theResponse to display dialog "Enter tasks:" default answer "
" buttons {"Cancel", "Continue"} default button "Continue"
Running your AppleScript code from Script Editor on a US English MacBook Pro, whether or not something is typed in, fnenter presses the Continue button.
The same keyboard shortcut works on an US English Apple Magic Keyboard when connected to the MacBook Pro and I'd assume any US English Mac it was connected to would do the same. I only have the MacBook Pro to test with at the moment.
In macOS, by default, pressing the tab key in this use case will not move between the controls as the controlling setting in System Preferences > Keyboard > Shortcuts is not set to allow it to act on all controls.
You must select one of the following options, depending on the version of macOS one is running, in order to use the tab key on all controls.
If you see:
Full Keyboard Access: In windows and dialogs, press Tab to move keyboard focus between:
(•) Text boxed and lists only
( ) All Controls
Select: (•) All Controls
If you see:
[] Use keyboard navigation to move between controls
Press the Tab key to move focus forward and Shift Tab to move focus backward.
Check: [√] Use keyboard navigation to move between controls
With this done, one can then use tabtabenter to press the continue button, with the dialog box produced by the code shown in the OP.
Side Note: One can also try fncommandenter as that was necessary from within a VMware macOS Catalina virtual machine that I also tested in.
⌘-Enter (on the numeric keypad) presses Continue
If you are in a multiline text field, hit the Tab key so that focus is on some element other than the text field. Then the Enter key should route properly to the dialog's default close button.
I am working in an MFC windows application. I am using Grid control with some icons and its properties are displaying with MFC Property Grid Control ( CMFCPropertyGridCtrl ). I need to implement tab navigation. I i am in some icon (let us assume "Star1") and when I press tab key it should go to its properties control ( MFC Property grid control) and focus on any field or group name.
I did try to capture keyboard events in PretranslateMessage(). but needs how to set focus on that specific field or group name?
I have implemented a button in my Office (Excel) add-in; clicking on the button will trigger a JavaScript function.
Does anyone know if it is possible to bind a keyboard shortcut to the button (or the function)? As a result, once users load the add-in, they could also use the keyboard shortcut to trigger the button / function.
Keyboard shortcuts are not currently possible, though you can certainly add it as a suggestion on our UserVoice: https://officespdev.uservoice.com/.
That said, if you are using Add-in Commands which allow you to add buttons to the ribbon (https://blogs.office.com/2015/09/28/whats-new-in-office-2016-for-developers/), a user can right-click on the button and add it to their Quick Access Toolbar.
Adding the button:
Using the button from the Quick Access Toolbar:
In my MFC application, which is a modeless dialog by itself, has a Tab control along with many other controls. And Tab control has two tabs, and dialogs are inserted into those.
This tab control is preceded and followed by other controls in the tabbing order. And when tab key gets to the tab control, It doesn't go into the dialogs inside tab, instead it moves to the next control in the application. I want that to go into the tab dialog and navigate through controls inside it.
At the moment, Tab key visits these dialogs inside tabs after visiting all controls in my application(modeless dialog).
How do I or where do I set tab order such that the tab key goes into the tab control dialogs ?
Research the WS_EX_CONTROLPARENT window style. MSDN:
"If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic."
What is the difference between a keyboard accelerator and a shortcut key?
John - I don't believe that is correct.
MSDN defines menus as having:
'Menu access keys' - the underlined letters in the menu item name.
'Menu shortcut keys' - the key combination to the right of the menu item.
It is menu shortcut keys (text to the right of the menu) that are identified as synonymous with keyboard accelerators, not menu access keys - see paragraph on Menu Shortcut Keys in the 'about menus' MSDN page - it is this section directs towards information on Keyboard accelerators, not the section on Menu Access Keys.
As far as I am concerned a keyboard accelerator is a 'shortcut key'. They may be used regardless of the visibility of a menu, and are only included in the menu as a reference for the user and a way for the user to pick up on shortcuts for menu items that they may regularly use. Hence they may be defined without being displayed in the menu at all.
See MSDN page on Keyboard Accelerators:
Typically, users rely on an
application's menus to learn the
command set and then switch over to
using accelerators as they become more
proficient with the application.
http://msdn.microsoft.com/en-us/library/ms646335(v=VS.85).aspx
Although accelerators typically
generate commands that exist as menu
items, they can also generate commands
that have no equivalent menu items.
http://msdn.microsoft.com/en-us/library/ms646335(v=VS.85).aspx
For Windows, a keyboard accelerator is represented by an underlined letter on a button, menu or other label:
keyboard accelerator http://content.screencast.com/users/TreefortJohn/folders/Jing/media/70d5002f-5832-448a-9379-256b7a8c4fd7/2009-01-12_2304.png
On recent versions of Windows, they are hidden until you press the Alt key. Then you can hit that letter to select the menu, button or other input control.
A shortcut key typically does not have a visual representation, except for when they're listed in menus. Ctrl-C, Ctrl-X, Ctrl-V are examples of common shortcut keys, which you can see listed next to their respective menu items.
About Keyboard Accelerators