definehotkeys
definehotkeys
SCOPE
,
KEY
,
CODE

The definehotkeys statement defines one or more Hotkeys.

Parameters

This statement has three parameters:

scope – the scope of the hotkey, which may be either global, database, or window. If left empty, the default is database. You can also use file instead of database.

key – is the key or keyboard combination that will trigger the hotkey. For single keys, simply use the key itself, for example `A`, `B`, or `X`. Usually you will want to use a combination of a regular key with one or more modifier keys, for example `FUNCTION-X` or `COMMAND-G`. Multiple modifiers can be combined, for example `SHIFT-FUNCTION-T`. (By the way, case is ignored, so `function-x` is the same as `FUNCTION-X`.) If you want a key to trigger no matter what modifier is pressed, use `ANYMODIFIER`, for example `ANYMODIFIER-P`. Some keys have special names, including `SPACE`, `TAB`, `DELETE`, `RETURN`, `ENTER`, `ESC`, `LEFT`, `RIGHT`, `UP`, `DOWN`, `HOME`, `PAGEUP`, `PAGEDOWN`, `HELP`, `DASH`, `KEYPAD0` thru `KEYPAD9` (separate from the regular `0` thru `9` keys) and `FUNCTION1` thru `FUNCTION15`. (Note: You can also use raw hex keycodes as described on pages 390–391 of the Panorama 6 Formulas & Programming book, for example `7A09` for `Command-Option-F1`.)

code – is the code to be run when the hotkey is triggered. If the code is empty, the hotkey will be deleted.

Description

This statement defines one or more hotkeys. This example sets up `CONTROL-R` as a hotkey that will open the Panorama Reference wizard. Since this hotkey has global scope, it will work in any database and any window.

    definehotkeys "global","control-r",{openwizard "Panorama Reference"}

A single definehotkeys statement can define multiple hotkeys at once.

    definehotkeys "database",
        "function-X","deleterecord",
        "option-function-X","removeunselected",
        "shift-function-X","deleteall"

The definehotkeys statement adds new hotkeys, but does not affect hotkeys that have already been defined. If the code below is run after the previous example, you will now have four hotkeys defined for the current database.

    definehotkeys "database","function-A","addrecord"

To delete an individual hotkey, leave the code parameter empty. This example deletes the hotkey for SHIFT-FUNCTION-X that was set up in an example above.

    definehotkeys "database","shift-function-X",""

To delete all of the hotkeys in a scope, use the deletehotkeys statement. This example deletes all of the hotkeys for the current database.

    deletehotkeys "database"

Note: Some key combinations are used by Mac OS X and are unavailable for use as Panorama hotkeys, for example `COMMAND-TAB`.

#### More About Scope

If you define a hotkey for window scope, that is for the current window. If you want to define a hotkey for some other window, you would first have to switch to that window. Usually if you wanted to define a hotkey for a particular window, you would do that right after the openform statement that opens the window, or if for a dialog, in the initialization code for that dialog.

The same rules apply for database scope – that is for the current database. In most cases you would probably set those up in the `.Initialize` procedure.

If one or more hotkeys are defined for a particular scope, those hotkeys go away when the scope goes away. So if you’ve defined hotkeys with window scope, those hotkeys will vanish when the window is closed, while database scope hotkeys will vanish when the database closes.

See Also

- deletehotkeys -- deletes the hotkeys in a specific scope.
- Hotkey Workshop -- tool that assists in composing a definehotkeys statement.
- info("keyboard") -- returns the last key that was pressed.
- info("keycode") -- returns a special numeric code that represents the last key that was pressed.

History

Version | Status | Notes
10.0 | New | New in this version.