Nevron Forum

NCommand Shorcuts

https://www.nevron.com/Forum/Topic3448.aspx

By Fabian Baptista 1 - Wednesday, April 28, 2010

I all, I'm having some troubles using shorcuts.
They are not allways executing Commands.

ie: I have a toolbar with a Ctrl + Shift +O (Open Command)
but if I don't have an active NDrawingDocument, this command not fire the "OnClick" event.
If y make my own class (extending NCommand class) and try to catch the "OnShorcut" event, isn't firing this too.

How can i deal with this situation?
Thanks in advance!
By Nevron Support - Tuesday, May 4, 2010

Hi Fabian,

This is the expected behavior of all commands that are managed by the NDiagramCommandBarsManager. This is because without a focused view (NDrawingView or NLibraryView) some of the commands become ambiguous. For example Ctrl-C and Ctrl-V need to know from which view you want to copy/paste.

You can override the GetFocusedView of the NDiagramCommander to provide a default focused view, if neither the library nor drawing view managed by the manager are focused. For example:

public class MyDiagramCommander : NDiagramCommander
{
...
public override NView GetFocusedView()
{
NView view = base.GetFocusedView();
return view == null? View: null;
}
...
}
...
nDiagramCommandBarsManager1.Commander = new MyDiagramCommander;

Hope this helps - questions or comments - please feel free...