Defining Events and Event Tables

Event tables are used for describing event or key bindings by source code, creating event-driven dialog boxes, and describing inheritance.

def Primitive

The def primitive is used to bind a key sequence or event to a command or procedure and is not typically used when creating event-driven dialog boxes. The defeventtab primitive selects the active event table that the def primitive sets the bindings to. If there is no defeventtab declaration before the first def primitive, the default_keys event table is used. The default_keys event table defines the event handlers for Fundamental mode. The source code representing the bindings is translated and then the event tables are loaded either by the load command or by executing the module as a batch program. For more information on batch programs, see defmain: Writing Slick-CŪ Batch Files. Even though executing the module as a batch program unloads the module when the defmain function terminates, the event table changes remain present. The following syntax is used for defining a key:


    def {prefix_key} event [- event] [, event [- event]] ... = [command];
    

command can be either a command (defined with _command) or global procedure. If command is not specified, the existing event is unbound. The words prefix_key and event may be any valid event name. Some event names do not need to be enclosed in quotes.

Example:

def "A-x"=safe_exit;
// Note that "A-a" is different than "A-A" which requires the Alt and Shift keys
// to be pressed. 
    def "A-?"=help;
    def "C-X" "b"=list_buffers;
    def \0 - \255= nothing;

The defeventtab primitive is used to define a new event table. The syntax for defining a an event table is:


    defeventtab name;
    

name may contain a period (.) character. The period is used to separate the form name from the control name. The def primitive changes the binding of events of the last event table defined. If no event table is defined, the default_keys event table is used.

Example:

defeventtab  c_keys;
    def " "=c_space;
    def "ENTER"=c_enter;

Event tables are global in scope. When an event table is loaded by the load command or by executing the module as a batch program, the new bindings replace the event bindings of the existing event table. If the event table specified by defeventtab does not exist, a new one is created.