Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - How to you use the ShortcutText Property?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to you use the ShortcutText Property?

 Post Reply Post Reply
Author
Message
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Topic: How to you use the ShortcutText Property?
    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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 2004 at 11:38pm

'ShortcutText' is obsolete. You must use KeyBindings only

CommandBars.KeyBindings.Add FCONTROL, Asc("X"), ID_EDIT_CUT
CommandBars.KeyBindings.Add FCONTROL, Asc("C"), ID_EDIT_COPY
CommandBars.KeyBindings.Add FCONTROL, Asc("V"), ID_EDIT_PASTE

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2004 at 8:19am

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:

  1. Let me specify that "Ctrl+C" is the text that should appear next to the ID_EDIT_COPY command when displayed in a menu without using KeyBindings
  2. Let me prevent the user from assigning "Ctrl+C" as a key binding when customizing a CommandBar.
  3. Let me prevent the user from assigning any other key binding to the ID_EDIT_COPY command.

What are your thoughts, Oleg?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2004 at 10:52am

What about this:

 

        Case ID_EDIT_CUT:
             Clipboard.SetText Screen.ActiveControl.SelText
             Screen.ActiveControl.SelText = vbNullString
        Case ID_EDIT_COPY:     Clipboard.SetText Screen.ActiveControl.SelText
        Case ID_EDIT_PASTE:    Screen.ActiveControl.SelText = Clipboard.GetText

it works with all TextlBox and RichEditBox.



Edited by oleg
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 05 May 2004 at 11:55am

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
Back to Top
markh View Drop Down
Groupie
Groupie


Joined: 12 November 2003
Location: United Kingdom
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote markh Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2006 at 12:28pm

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?

 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2006 at 12:50pm
You can remove KeyBindings but specify ShortcutText for these controls.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.