Create custom shortcut combination not contained in the System.Windows.Forms.Shortcut enumeration
 

Consultingwerk Blog

Create custom shortcut combination not contained in the System.Windows.Forms.Shortcut enumeration

by Marko Rüterbories | Oct 07, 2011

The usage of shortcuts is one of the key features to enable the user to use an application completely using the keyboard. When using the OpenEdge Architect we all know that Ctrl + S saves the current changes from for example code files. In an ABL GUI for .NET application this is typically achieved by assigning a shortcut key from the System.Windows.Forms.Shortcut enumeration to a menu item or ribbon tool – no matter if you are using the toolbar and menu components from Microsoft or Infragistics. A common concern of developers moving from the ABL GUI to the GUI for .NET is that the ABL GUI seems to support more combinations of the modifier keys (CTRL, ALT, SHIFT) and regular keys or cursor keys.

Within C# you just combine the desired keys using a bitwise or operator and then cast the result to System.Windows.Forms.Shortcut.

shorcut_code

To achieve the same in the ABL you first have to combine the desired key enum values using the bitwise or operator (Progress.Util.EnumHelper:Or) and cast the result to Int32 (Progress.Util.CastUtil:ToInt32) and convert that into an Enum object of the type (System.Windows.Forms.Shortcut)  using (System.Enum:ToObject). Finally you can cast that object reference to the System.Windows.Forms.Shortcut type.

ABL-Code3

The object referenced in the instance variable oShortcut can then be assigned to for example the Infragistics.Win.UltraWinToolbars.SharedProps:Shortcut property related to a ButtonTool object.

As a slightly more usual example is the following code which creates a shortcut ALT + A, which is typically used by menu mnemonics and thus not foreseen in the Shortcuts collection.

ABL-Code-AltA