How to you use the ShortcutText Property? |
Post Reply |
Author | |
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
Posted: 04 May 2004 at 3:11pm |
According to the help file, the 'ShortcutText' property 'Gets/Sets the shortcut text of the control'. Since there's no clear definition of what 'shortcut text' refers to, I assume this is the text representing the shortcut key that initiates the control (i.e. "Ctrl+X" is the shortcut text for a "Cut" command). When I set this property for a control, I cannot determine any impact it has on the control. For controls that have an associated accelerator key, this property always returns an empty string. So what does this property do? Most applications have Cut/Copy/Paste functionality, and these items often appear in the 'Edit' menu. I would like for "Ctrl+X", "Ctrl+C", and "Ctrl+V" to be displayed next to these menu items, and I thought that setting the 'ShortcutText' property for these controls would accomplish the task. Unfortunately, it had no effect that I could detect. Of course, I could bind each control to the appropriate accelerator key (which does produce the desired text in the menu system), but this overrides the standard functionality of any control that already uses these shortcuts (like TextBoxes). Any help from Codejock or other users is greatly appreciated. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
'ShortcutText' is obsolete. You must use KeyBindings only CommandBars.KeyBindings.Add FCONTROL, Asc("X"), ID_EDIT_CUT
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
Thanks for the follow-up. You may want to update your Help file to indicate that the property is obsolete. I guess you can consider this a feature request. Here's the problem... I have an MDI application where the MDI Child is basically an editor. I also have various docking panes that include textboxes and property grids. The TextBoxes have built-in support for handling the clipboard shortcuts Ctrl+X, Ctrl+C, & Ctrl+V. The Property grid also has built-in support for these command when editing an item. The 'Edit' menu for my application primarily controls the editor in the MDI Child window. If I want "Ctrl+X" to appear next to the "Cut" command, you're saying I have to bind that key combination to the Cut command. The problem is that "Ctrl+X" is now ALWAYS associated with that menu item. If I type "Ctrl+X" in my textbox or the property grid, it doesn't accept it. Instead, it sends the command to my editor (due to the key binding). The Office 2003 Sample application illustrates this problem. In the search pane, there is a TextBox used at the bottom of the pane. Type any value in this box and then highlight the entire word. Right-click and select 'Cut' from the popup menu. Now (with focus still in the search box), type "Ctrl+V". This SHOULD paste the value you just cut back into the textbox. Instead, it pastes the value into the Editor because "Ctrl+V" is bound to the command that pastes in the editor. The RTF Control used as the editor and the TextBox used for search already recognize these commands, so the key bindings are unnecessary. Having this text in the menu, however, helps reinforce to the user what the shortcut keys are and be consistent with other controls that might be displaying Shortcut Text due to KeyBindings. If you look at the following post by 'elias', you'll see that I'm not the only one who would like to see some flexibility here: https://forum.codejock.com/forum_posts.asp?TID=686&P N=1 I hope you will consider some alternatives. As part of this feature request, it would be nice if the programmer could reserve certain shortcut keys from being defined by the user as a key binding when customizing a toolbar. This would allow the programmer to prevent the user from assigning "Ctrl+C" to some random command when it could be reserved for the "Copy" command. Along the same line of thinking, it would be nice to prevent the user from assigning any key binding to a particular control. In other words, here's a summary of my request:
What are your thoughts, Oleg? |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
What about this:
Case ID_EDIT_CUT: it works with all TextlBox and RichEditBox. Edited by oleg |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
True, this works in the simpliest of cases. But not all controls support these properties. For instance, your PropertyGrid control allows you to directly edit values in the grid. While editing a value, I can use shortcuts for Cut (Ctrl+X), Copy (Ctrl+C) and Paste (Ctrl+V). The PropertyGrid doesn't expose any equivalent methods for .GetText and .SelText as a value is being edited. So if I've bound those shortcut keys to a CommandBarControl, how would I detect and route the appropriate shortcut to the PropertyGrid? As each application adds more and more controls, the procedure of detecting and routing the command becomes more and more complicated. It would be easier (and less error prone) to simply not bind the keys at all and allow each control to intercept the shortcuts in the manner it was designed. Of course, that prevents the shortcut text from being displayed within the menu system. Edited by Boyd |
|
markh
Groupie Joined: 12 November 2003 Location: United Kingdom Status: Offline Points: 49 |
Post Options
Thanks(0)
|
This has become a major issue in my application as well. Basically CommandBars steals any accelerator keys that are added to KeyBindings and gives the developer no opportunity to override this behaviour. This means in my app that shortcut key commands such as Cut/Copy/Paste etc. cannot ever be received in child windows such as those contained in DockingPanes etc. since the CommandBars in the main application window steals them. The only way to allow the accelerators to get through is to remove them from the KeyBindings. However, there is then no way to have the keyboard shortcut displayed nicely right-aligned in the application's main menu. I just wondered if this issue is likely to be addressed in the Version 10 release?
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
You can remove KeyBindings but specify ShortcutText for these controls.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |