
|
- Written and documented by David Deley
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12.1: 12.2: 12.3: 12.4:
Introduction to CMac Chapter 11: Defining a key to run a macro
In this example the keypad 7 key is defined as the "GOLD Key" which performs a mode shift. To get the GOLD key function you first press the GOLD key (keypad 7) then press the key you want. For example, if you press the GOLD (keypad 7) key followed by the keypad 6 key, you get a "paste" operation, whereas if you just pressed the keypad 6 key without first pressing the GOLD key it performs a "cut" operation. Another example, if you press the GOLD (keypad 7) key followed by the keypad 4 key, the cursor will move to the end of the file (bottom). Or if you press the GOLD (keypad 7) key followed by the keypad 5 key, the cursor will move to the beginning of the file (top). [We used to print these words on sticky paper, cut out the words, and affix the words to the front of the keys themselves. We would highlight the lower word indicating it was the GOLD key function while leaving the top word unhighlighted. That way our users could look at the keys themselves to see what functions the keys performed. The yellow highlighting is is probably where the idea of calling the mode shift key the GOLD key came from.] To define the keypad 7 key as a mode shift key: Click "Insert" to insert a new command as we did above and fill in the fields as follows:
NAME: GOLD Key COMMAND LINE: 207 (Here you choose any number you want other than 0. This is the mode shift number we are shifting to. It doesn't matter what number you choose. EDX uses 207, which is a number I just made up at random, so don't use 207 unless you want to intergrate with the EDX add-on package.) TYPE: set to MODE SHIFT PRIMARY KEY: To set the primary key click the
button to the right of the Primary Key field, then press the key you
want to define. For our example, set the Primary Key field to the
Keypad 7 key (which will show up as "Num 7").
Mode: Leave this be with a 0 in it. Reset Mode (box): Leave Unchecked. Click OK when finished. This defines the keypad 7 key to be the mode shift "GOLD" key. When you press the keypad 7 key the words "GOLD Key" will show up in the message area at the lower left of the Multi-Edit screen. Now to define the keypad 4 key to be "move cursor to end of file" after the GOLD key is pressed, click "Insert" to insert a new command as we did above and fill in the fields as follows:
NAME: End of File COMMAND LINE: 10 (10 happens to be the Multi-Edit internal command number which moves the cursor to the end of the file. We must set Type to COMMAND for this to work.) TYPE: set to COMMAND PRIMARY KEY: To set the primary key click the
button to the right of the Primary Key field, then press the key you
want to define. For our example, set the Primary Key field to the
Keypad 4 key (which will show up as "Num 4").
Mode: 207 (This is where we put the mode number we shifted to via the GOLD key defined above. This means this key is defined for mode 207. (The usual default mode is 0.) ) Reset Mode (box): Checked. Thus pressing the key will complete the mode shift key sequence and return us back to the default mode 0. Click OK when finished. Now the key sequence Keypad 7 followed by Keypad 4 will move the cursor to the end of the file. What happens if you accidentally press the GOLD key (keypad 7) and decide you didn't want it? The user needs a way to cancel the mode shift. I suggest defining the GOLD key so if you press it a second time it will cancel the mode shift. This gives the user a way out. Click "Insert" to insert a new command as we did above and fill in the fields as follows:
NAME: Cancel Gold Key COMMAND LINE: 0 (Return to mode 0) TYPE: set to MODE SHIFT PRIMARY KEY: To set the primary key click the
button to the right of the Primary Key field, then press the key you
want to define. For our example, set the Primary Key field to the
Keypad 7 key (which will show up as "Num 7").
Mode: 207 (This is where we put the mode number we shifted to via the GOLD key defined above. This means this key is defined for mode 207. (The usual default mode is 0.) ) Reset Mode (box): Checked. Thus pressing the key will complete the mode shift key sequence and return us back to the default mode 0. Click OK when finished. Now the key sequence Keypad 7 followed by Keypad 7 again will cancel the mode shift. The words "Cancel GOLD Key" will show up in the message area at the bottom left of the Multi-Edit screen. See Smooth Scroll, Scroll Margins, Editing Keypad (EDX) for an example. You can temporarily install the add-on package, then take a look at the commands it defines, then uninstall the package if you don't want to keep it. RELATED ARTICLES: Introduction to CMAC. 1: Hello World Introduction to CMAC. 2: Hello World II Introduction to CMAC. 6: Command Map Report Smooth Scroll, Scroll Margins, Editing Keypad (EDX) 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12.1: 12.2: 12.3: 12.4: |