#include <ivplus/virtual.h>
Mouse events may be described in terms of virtual buttons, and key events may be described in terms of virtual keys. The term virtual implies that the events as described do not necessarily correspond to a fixed set of X Window System events. Instead, virtual buttons and keys are linked to actual events by means of virtual bindings.
InterViews Plus performs a mapping on incoming key events according to mapping information contained in a virtual binding string. This string may be specified through the mechanism described in "BINDINGS FOR OSF KEYSYMS" below. When a key event is encountered that matches the binding specification, its keysym and keystring fields are replaced with the corresponding osf keysym and keystring. These keysyms and keystrings are available for programmatic use in <ivplus/virtual.h>. Any modifiers which were required to perform the mapping will be removed. An application should compare event keysyms or keystrings with the names defined in virtual.h, not with the values themselves.
See NOTE at the end of this manual entry for information on disabling the virtual key-binding mechanism.
Both virtual buttons and virtual keys may contain virtual modifiers. Each virtual modifier corresponds to one or more actual modifiers. The following table lists the bindings of virtual modifiers to actual modifiers in InterViews Plus.
Virtual Modifier Bindings | |
Virtual Modifier | Actual Modifier |
MAlt | |
MCtrl | |
MShift |
Mod1refers to the first modifier key. OSF/Motif requires that it correspond to either Altor Meta.The current release of InterViews Plus considers Altand Metato be indistinguishable. This may change in future releases. Virtual ButtonsEach virtual button corresponds to one or more actual button event descriptions. Each button event description contains a button name and optional modifiers. These button event descriptions, appropriately ordered and possibly further modified, are used in translation tables. The following table lists the bindings of virtual buttons to actual button event descriptions. Virtual Button BindingsVirtual ButtonActual Button Events BCustomBDragBExtendBMenuBSelectBToggle Virtual KeysEach virtual key corresponds to one or more actual key event descriptions. Each key event description contains a keysym name and optional modifiers. These key event descriptions, appropriately ordered and possibly further modified, are used in translation tables. The following table lists the bindings of virtual keys to actual key event descriptions in InterViews Plus (where multiple events are listed on the right hand side, any of them will do, though some may not be accessible from certain keyboards): Virtual Key BindingsVirtual KeyActual Key Events KActivateKAddModeKBackSpaceKBackTabKBeginDataKBeginLineKCancelKClearKCopyKCutKDeleteKDeselectAllKDownKEndDataKEndLineKEnterKEscapeKExtendKHelpKInsertKLeftKMenuKMenuBarKNextFieldKNextMenu Virtual Key Bindings (Continued) Virtual KeyActual Key Events KPageDownKPageLeftKPageRightKPageUpKPasteKPrevFieldKPrevMenuKPrimaryCopyKPrimaryCutKPrimaryPasteKQuickCopyKQuickCutKQuickExtendKQuickPasteKReselectKRestoreKRightKSelectKSelectAllKSpaceKTabKUndoKUpKAny Bindings for Osf KeysymsKeysym strings that begin with osf are not part of the X server’s keyboard mapping. Instead, these keysyms are produced by an InterViews Plus application at run time and are used by the translation manager when the server delivers an actual key event. A mapping is maintained by InterViews Plus between osf keysyms and actual keysyms. This mapping is based on information obtained from exactly one of the following sources (i.e., there is no augment/merge/override mechanism such as that provided with event translation specifications). The possible sources of the mappings are listed here in order of precedence: A _MOTIF_BINDINGS property on the root window of screen 0. A Motif-compliant Window Manager will set this property when it starts up, taking the contents from the .motifbind file in the user’s home directory. A defaultVirtualBindings application resource in the resource database. A fixed default based on the vendor string returned by the X server during the call to XOpenDisplay(). A fixed fallback default. The format of the specification for mapping osf keysyms to actual keysyms is similar to that of a specification for an event translation. The syntax is specified here in EBNF (Extended Backus Normal Form) notation using the following conventions: [a] Means either nothing or a {a} Means zero or more occurrences of a Terminals are enclosed in double quotation marks. The syntax of an osf keysym binding specification is as follows: binding_spec={line "\n"} [line]line=virtual_keysym ":" key_eventkey_event={["~"] modifier_name} "<Key>" actual_keysymvirtual_keysym=keysymactual_keysym=keysymkeysym=A valid X11 keysym name that is mapped by XStringToKeysym().modifier_name="Alt" | "a" |"Ctrl" | "c" |"Lock" | "l" |"Meta" | "m" |"Shift" | "s" The order in which modifier names appear is unimportant. As with event translations, more specific event descriptions must precede less specific descriptions. For example, an event description for a key with a modifier must precede a description for the same key without the same modifier. Following is an example of a specification for the defaultVirtualBindingsresource in a resource file: *defaultVirtualBindings: osfBackSpace : Ctrl <Key>BackSpace "\n" osfInsert : s <Key>InsertChar "\n" osfDelete : <Key>DeleteChar
The format of a .motifbind file is the same, except that the binding specification for each keysym is placed on a separate line. The example specification above appears as follows in a .motifbind file:
osfBackSpace : Ctrl <Key>BackSpace osfInsert : s <Key>InsertChar osfDelete : <Key>DeleteChar
The following table lists the HP default bindings for osf keysyms:
The following bindings are used when no _MOTIF_BINDINGS property is found on the root window, no application resource defaultVirtualBindings is found for the application, and the vendor string for the X display is "Hewlett-Packard Company."""
HP Default Bindings for osf Keysyms | |
osf Keysym | Default Binding |
osfActivate | |
osfAddMode | |
osfBackSpace | |
osfBeginLine | |
osfCancel | |
osfClear | |
osfCopy | |
osfCut | |
osfDelete | |
osfDown | |
osfEndLine | |
osfHelp | |
osfInsert | |
osfLeft | |
osfMenu | |
osfMenuBar | |
osfPageDown | |
osfPageUp | |
osfPaste | |
osfPrimaryPaste | |
osfQuickPaste | |
osfRight | |
osfSelect | |
osfUndo | |
osfUp |
The following bindings are used when no _MOTIF_BINDINGSproperty is found on the root window, no application resource defaultVirtualBindingsis found for the application, and the vendor string for the X display is "X11/NeWS"- Sun Microsystems Inc."" There are two possible keyboard mappings for Sun keyboards, and InterViews Plus cannot currently distinguish between them. The first binding set below is the one which is used by InterViews Plus when it detects it is connected to a Sun display. If these bindings are incorrect, they may be overridden using the second set of bindings in a .motifbindfile (reformatted for syntax) or as an application resource. Sun Default Bindings for osf Keysymsosf KeysymDefault Binding osfActivateosfAddModeosfBackSpaceosfBeginLineosfCancelosfClearosfCopyosfCutosfDeleteosfDownosfEndLine Sun Default Bindings for osf Keysyms(Continued)osf KeysymDefault Binding osfHelposfInsertosfLeftosfMenuosfMenuBarosfPageDownosfPageUposfPasteosfPrimaryPasteosfQuickPasteosfRightosfSelectosfUndoosfUp Alternate Sun Bindings for osf Keysymsosf KeysymDefault Binding osfActivateosfAddModeosfBackSpaceosfBeginLineosfCancelosfClearosfCopyosfCutosfDeleteosfDownosfEndLineosfHelposfInsertosfLeftosfMenuosfMenuBarosfPageDownosfPageUposfPasteosfPrimaryPasteosfQuickPasteosfRightosfSelectosfUndoosfUp The following bindings are used when no _MOTIF_BINDINGSproperty is found on the root window, no application resource defaultVirtualBindingsis found for the application, and the vendor string for the X display is not recognized. Fallback Default Bindings for osfKeysymsosf KeysymFallback Default Binding osfActivateosfAddModeosfBackSpaceosfBeginLineosfCancelosfClearosfCopyosfCutosfDeleteosfDownosfEndLineosfHelposfInsertosfLeftosfMenuosfMenuBarosfPageDownosfPageUposfPasteosfPrimaryPasteosfQuickPasteosfRightosfSelectosfUndoosfUp ExamplesLook for various osf key events in Handle(): #include <ivplus/virtual.h> class MyEditor : public Interactor { public: ... virtual void Handle(Event& e); } void MyEditor::Handle(Event& e) { if (e.eventType == KeyEvent) { switch (e.keysym) { case OsfKeysymCopy: { /* do copy */ } case OsfKeysymBackSpace: { /* back up */ } case OsfKeysymDelete: { if (e.meta) { /* delete a word, just to be different */ } else { /* delete char */ } default: } } }