22.3 Gestures and Gesture Names

  • 22.3.1 Standard Gesture Names
  • A gesture is some sort of input action by the user, such as typing a character or clicking a pointer button. A keyboard gesture refers to those gestures that are input by typing something on the keyboard. A pointer gesture refers to those gestures that are input by doing something with the pointer, such as clicking a button. [annotate]

    [gesture, Concept← A Glossary]
    [gesture, Concept← A Glossary]

    A gesture name is a symbol that gives a name to a set of similar gestures. Gesture names are used in order to provide a level of abstraction above raw device events; greater portability can thus be achieved by avoiding referring directly to platform-dependent constructs, such as character objects that refer to a particular key on the keyboard. For example, the :complete gesture is used to name the gesture that causes the complete-input complete the current input string; on Genera, this may correspond to the Complete key on the keyboard (which generates a #\Complete character), but on a Unix workstation, it may correspond to some other key. Another example is :select, which is commonly used to indicate a left button click on the pointer. [annotate]

    Note that gesture names participate in a one-to-many mapping, that is, a single gesture name can name a group of physical gestures. For example, an :edit might include both a pointer button click and a key press. [annotate]

    CLIM uses event objects to represent user gestures. Some of the more common events are those of the class pointer-button-event. Event objects store the sheet associated with the event, a timestamp, and the modifier key state (a quantity that indicates which modifier keys were held down on the keyboard at the time the event occurred). Pointer button event objects also store the pointer object, the button that was clicked on the pointer, the window the pointer was over and the x and y position within that window. Keyboard gestures store the key name. [annotate]

    In some contexts, the object used to represent a user gesture is referred to as an gesture object. An gesture object might be exactly the same as an event object, or might contain less information. For example, for a keyboard gesture that corresponds to a standard printing character, it may be enough to represent the gesture object as a character. [annotate]

    define-gesture-name  name type gesture-spec &key (unique t) [Macro]
              

    Defines a new gesture named by the symbol name. type is the type of gesture being created, and must be one of the symbols described below. gesture-spec specifies the physical gesture that corresponds to the named gesture; its syntax depends on the value of type. define-gesture-name must expand into a call to add-gesture-name. [annotate]

    If unique is true, all old gestures named by name are first removed. unique defaults to t. [annotate]

    None of the arguments to define-gesture-name is evaluated. [annotate]

    [annotate]

    add-gesture-name  name type gesture-spec &key unique [Function]
              

    Adds a gesture named by the symbol name to the set of gesture names. type is the type of gesture being created, and must be one of the symbols described below. gesture-spec specifies the physical gesture that corresponds to the named gesture; its syntax depends on the value of type. [annotate]

    If unique is true, all old gestures named by name are first removed. unique defaults to nil. [annotate]

    When type is :keyboard, gesture-spec is a list of the form (key-name . modifier-key-names). key-name is the name of a non-modifier key on the keyboard (see below). modifier-key-names is a (possibly empty) list of modifier key names (:shift, :control, :meta, :super, and :hyper). [annotate]

    For the standard Common Lisp characters (the 95 ASCII printing characters including #\Space), key-name is the character object itself. For the other "semi-standard" characters, key-name is a keyword symbol naming the character (:newline, :linefeed, :return, :tab, :backspace, :page, and :rubout). CLIM implementations may extend the set of key names on a per-port basic, but should choose a port-specific package. For example, the Genera port might such gestures as include genera-clim:help and genera-clim:complete. [annotate]

    The names of the modifier keys have been chosen to be uniform across all platforms, even though not all platforms will have keys on the keyboard with these names. The per-port part of a CLIM implementation must simply choose a sensible mapping from the modifier key names to the names of the keys on the keyboard. For example, a CLIM implementation on the Macintosh might map :meta to the Command shift key, and :super to the Option shift key. [annotate]

    When type is :pointer-button, :pointer-button-press, or :pointer-button-release, gesture-spec is a list of the form (button-name . modifier-key-names). button is the name of a pointer button (:left, :middle, or :right), and modifier-key-names is as above. [annotate]

    CLIM implementations are permitted to have other values of type as an extension, such as :pointer-motion or :timer. [annotate]

    As an example, the :edit gesture name above could be defined as follows using define-gesture-name: [annotate]

    (define-gesture-name :edit :pointer-button (:left :meta))
    (define-gesture-name :edit :keyboard (#\E :control))
    

    [annotate]

    delete-gesture-name  name [Function]
              

    Removes the gesture named by the symbol name. [annotate]

    [annotate]

    event-matches-gesture-name-p  event gesture-name [Function]
              

    Returns true if the device event event "matches" the gesture named by gesture-name. [annotate]

    For pointer button events, the event matches the gesture name when the pointer button from the event matches the name of the pointer button one of the gesture specifications named by gesture-name, and the modifier key state from the event matches the names of the modifier keys in that same gesture specification. [annotate]

    For keyboard events, the event matches the gesture name when the key name from the event matches the key name of one of the gesture specifications named by gesture-name, and the modifier key state from the event matches the names of the modifier keys in that same gesture specification. [annotate]

    [annotate]

    modifier-state-matches-gesture-name-p  modifier-state gesture-name [Function]
              

    Returns true if the modifier key state from the device event event matches the names of the modifier keys in one of the gesture specifications named by gesture-name. [annotate]

    Minor issue: Note that none of the functions above take a port argument. This is because CLIM implicitly assumes that the canonical set of gesture names is the same on every port, and only the mappings differ from port to port. Some ports may define additional gesture names, but they will simply not be mapped on other ports. Is this a reasonable assumption? --- SWM [annotate]

    [annotate]

    make-modifier-state  &rest modifiers [Function]
              

    Given a list of modifier state names, this creates an integer that serves as a modifier key state. The legal modifier state names are :shift, :control, :meta, :super, and :hyper. [annotate]

    [annotate]

    22.3.1 Standard Gesture Names

    Every CLIM implementation must provide a standard set of gesture names that correspond to a common set of gestures. These gesture names must have a meaningful mapping for every port type. [annotate]

    Here are the required, standard keyboard gesture names: [annotate]

    Here are the required, standard pointer gesture names: [annotate]