[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide



Focus Models

Motif provides two models for determining which widget within an application receives keyboard events. The focus model is determined for all descendants of a VendorShell by the value of the VendorShell resource XmNkeyboardFocusPolicy:

  1. When the value is XmEXPLICIT, the widget under the pointer does not necessarily receive keyboard events. The user must take an action other than moving the pointer to transfer keyboard focus to a widget. The user can usually transfer focus to a widget by pressing Btn1 on that widget or by using a keyboard navigation action to traverse to the widget.

    When the value is XmEXPLICIT, a widget must be traversable to receive keyboard events. In general, a widget is traversable when its XmNsensitive, XmNancestorSensitive, and XmNtraversalOn resources are True and when the widget and its ancestors are managed, realized, mapped, and viewable. See Section 13.2 for more information.

  2. When the value is XmPOINTER, the widget under the pointer receives keyboard events, unless that widget is insensitive. Keyboard navigation operations are not available. However, the user can still use the keyboard to traverse a menu system. Pressing osfMenuBar moves focus to the MenuBar, and osfMenu posts a PopupMenu if available. When the user posts a menu by using osfMenu or Btn1Up, osfActivate, or osfSelect in a CascadeButton, keyboard navigation operations are available in the menu until the menu is unposted. When the user exits the menu system, keyboard focus returns to the widget under the pointer.

    MWM provides two parallel focus models for determining which top-level window receives keyboard events. The focus model is determined by the value of the mwm resource keyboardFocusPolicy:

    1. When the value is "explicit", the window under the pointer does not necessarily receive keyboard events. The user must take an action other than moving the pointer to transfer keyboard focus to a window. The user can usually transfer focus to a window by pressing osfSelect on that window or by using AltF6, AltTab, AltShiftTab, AltShiftF6, AltShiftEsc, or AltEsc to traverse to the window.

    2. When the value is "pointer", the widget under the pointer receives keyboard events. Keyboard window navigation operations are not available.

      When the focus policy is "explicit", four Boolean mwm resources can be set to True to allow a window to receive keyboard focus automatically at specified times:

      autoKeyFocus
      When the window with focus is iconified or unmapped (gives focus to the window that last had it)

      deiconifyKeyFocus
      When the window is iconified

      raiseKeyFocus
      When the window is raised to the top of the stack

      startupKeyFocus
      When the window is mapped


    3. [ Previous | Next | Contents | Glossary | Home | Search ]