How to use library

Using is very simple, everything what you need to do is subscribe shortcut and create handler method. Every shortcut is represented by it's ShortcutInfo class. You can supply this class when you want subscribe or unsubscribe shortcut.

ShortcutInfo info = new ShortcutInfo(KeyModifiers.Control | KeyModifiers.Alt, Key.S, MyEventHandler);

The other way is create and subscribe shortcut by calling overloads of Subscribe method.

ShortcutInfo shortcut = ShortcutManager.Subscribe(KeyModifiers.Alt, Key.X, MyEventHandler);

Last optional parameter for shortcut is form instance. If isn't supplied, shortcut is global, what means that handler is invoked even when application is minimalized. In similar way you can unsubscribe shortcut using Unsubscribe method. Handler method delegate is type of SM.ShortcutEventHandler.

public delegate void ShortcutEventHandler(ShortcutInfo shortcutInfo, ref bool handled);

If you can handle shortcut and want to be the last who can handle it, set handled parameter to true.

private void MyEventHandler(ShortcutInfo shortcutInfo, ref bool handled)
    // ...

    handled = true;

Last edited Nov 13, 2011 at 5:45 PM by CSharpDeveloping, version 1


No comments yet.