Adding Keyboard Shortcuts
As is usual for a RiscOS application, most TW/EW functions can be accessed via the menus. The menu system is controlled by the MenuData file inside TW/EW. Although there isn’t much point in trying to rearrange the actual Menu system, this data also ‘binds’ menu actions to the keyboard. For this reason it is possible to alter the contents of the MenuData file so as to add new keyboard actions, or modify the current keyboard actions. You can therefore ‘customise’ TW/EW's keyboard shortcuts to suit your personal preferrences.
HEALTH AND SANITY WARNING!
If you make any changes based on what follows, please remember:
- Always take a backup copy of the unmodified MenuData file so you can get black to normal operation if you get into trouble.
- Take care, no-one (not me, not Icon Tech) take any responsibility if making changes gives you grief.
- Make a detailed note of any changes you make to the MenuData file. You will have to repeat them again if you get an upgraded version of EW/TW and want the new version to include your ‘improvements’.
The control and data format used in the MenuData file is basically fairly simple (although some lines are more complex). The syntax is defined as follows:
Menu header = :<menu name>,<menu number>;
Menu items = <item name>,<cmd number>[,options];
options = | next line is dashed;
> dialogue submenu;
}<menu num> menu submenu;
$<menu num> automatic submenu;
¤[C][S]F-n [Ctrl][Shift]Function key n;
# input number;
? input text;
By way of illustration, here are a few lines taken from the file for TW Pro Version 5.02
This section of the file controls the layout and behaviour of the Save and Edit submenus. The leading colon, ‘:’ is used to indicate the title of a new menu or submenu.
Each item is a comma separated list. The first item being the name you see in the menu, and the second being an internal number that links all the actions together. Here we will ignore these and concentrate on the third item – options – (where they are present!) on each line.
For example, take the second line which defines the linking of the Document item. After the second comma there is a closing angle-bracket, ‘>’. This means there will be a submenu. Following this there is the string ‘¤F-3’. It is this string we’re interested in. The initial currency symbol, ‘¤’ (char 164) tells the application that this is a key binding.
The specification of the key binding is in two parts. The section before the dash ‘-’ indicates whether it is a function key or a normal character key, and whether any other modifiers are used. In this case, the ‘F’ tells the program that this is a function key. The number after the dash then tells the program which key. So in this case we can see that ‘¤F-3’ means the F3 function key.
If you look down to the Area as Draw line, you’ll see a similar key binding, but with a ‘C’ in front of the ‘F’. As you would expect, this means <Ctrl>F, so this string means the Area as Draw function can be called by <Ctrl>F3. - i.e. by pressing the control key and the F3 key together. Just as ‘C’ before the dash means <Ctrl>, so ‘S’ before the dash means <Shift>.
When they key being invoked is an ordinary character key, the dash is followed by the key character. So, for example, the Paste line binds <Ctrl>V to the paste action by using the string, ‘¤C-V’.
Knowing the format of the way these strings are used to bind menu actions to the keyboard, you can now modify or add your own keyboard shortcuts for menu actions. For example, a change I make to my own MenuData file is to alter the line
As a result the menu now displays the ‘F1’ keyboard shortcut after the ‘Button bar’ item and I can press the F1 function key to toggle the visibility of the Button bar. This is a fairly trivial example, but is shows how you can link any menu item to a key of your choice.
The ‘Pro Plus’ versions of TechWriter and EasiWriter now have considerably extended the ability to redefine the actions that can be obtained via a series of extended keyboard functions.
Back to the main TechWriter Tips page for more info...
Pages written using TW Pro and HTMLEdit
Content and pages maintained by: Jim Lesurf (email@example.com)