locked
How to set hotkey for control 's context menu RRS feed

  • Question

  • I have created some custom controls derived from the standard controls and a context menu provider which derived from PrimarySelectionContextMenuProvider which provided some custom menus. Menus are added into the Items property which is used MenuAction instance. 

    How can i assign a hotkey such as Ctrl+L or Ctrl+G for those menus.

    Thanks in advance.

    Thursday, March 15, 2012 9:39 AM

Answers

  • If bindings exist for the commands declaring conflicting bindings will not work, VS does not say whose binding would win, it may not even be the same machine to machine as it would depend on the processing order of the contributions. You would need to introduce a new binding scope but only the window owner (the designer) can do that. VS doesn't work on events so I don't know how or even if you could create such events for the designer to consume.

    Ryan

    • Marked as answer by lucy-liu Wednesday, March 21, 2012 8:16 AM
    Friday, March 16, 2012 5:21 AM

All replies

  • I don't think this is a VS extensibility question. I have never heard of PrimarySelectionContextMenuProvider but looking on MSDN it doesn't appear to be VS related/specific.

    Ryan

    Thursday, March 15, 2012 2:36 PM
  • That provider class are used to extend wpf designer, so the controls who is applied for this class will have some custom menu when you right click on the control in wpf designer. 

    I am looking for the way to set the hotkey for the wpf designer to invoke those menus. I have tried to add some entry to the InputBindings properties of the DesignerView but it just works for key which is not assigned for any VS commands such as Ctrl + G, the others like Ctrl+L, Ctrl+B show nothing.

    Thursday, March 15, 2012 3:02 PM
  • It sounds like the WPF designer is trying to pretend the VS command system doesn't exist or is the same as WPF. Both are false, if they haven't done things to make WPF keybindings work (ala calling RaiseThreadMessage in their window's PreProcessMessage callback) then there is nothing you can do to make it work. I would file a Connect bug against the designer.

    Ryan

    Thursday, March 15, 2012 3:17 PM
  • Do you have any work around solution instead of waiting for a hotfix?
    Thursday, March 15, 2012 3:26 PM
  • There is no possible work around, the WPF designer is apparently not using the VS command system. WPF command system is not the same or in any way related to / integrated with the VS command system. If non-conflicting bindings work then perhaps you could remove the conflicting bindings, but that tends to piss people off (your extension monkeying around with their keybindings).

    Ryan

    Thursday, March 15, 2012 4:21 PM
  • Can we declare commands in vspackage file in extension project with key bindings as expected, and then dispatch the event to the designer? 

    How do I dispatch events?

    Friday, March 16, 2012 4:19 AM
  • If bindings exist for the commands declaring conflicting bindings will not work, VS does not say whose binding would win, it may not even be the same machine to machine as it would depend on the processing order of the contributions. You would need to introduce a new binding scope but only the window owner (the designer) can do that. VS doesn't work on events so I don't know how or even if you could create such events for the designer to consume.

    Ryan

    • Marked as answer by lucy-liu Wednesday, March 21, 2012 8:16 AM
    Friday, March 16, 2012 5:21 AM