Home |
Windowing Interface Terminology Input Focus Tree |
Input Focus TreeAn additional task of PegPresentationManager is message routing. Many system messages, such as mouse and keyboard input messages, are not directed to any particular object. For this reason, PegPresentationManager internally maintains a pointer to the object that was last selected by the user using the mouse or other input means. This object is called the current or input object, meaning that by default this object will receive input messages. PEG views each displayed window and child objects of each window as branches in a tree. When input focus moves from object to object, PegPresentationManager insures that the entire branch of the tree up to the actual input object has input focus. Whether an object is a member of the input focus branch of the presentation tree can be detected at run-time time by testing the PSF_CURRENT system status flag: if (StatusIs(PSF_CURRENT)) { // this object is in the branch // of the display tree that has input focus. } Just because an object is a member of the input focus tree does not mean the object is the end or leaf of the input focus branch. A pointer to the final input object is returned by PegPresentationManager::GetCurrentThing(). An application can override the user's input selection and manually command PegPresentationManager to move the input focus by calling the PegPresentationManager::MoveFocusTree() function. MoveFocusTree() will set input focus to the indicated object by sending PM_NONCURRENT messages to objects that are no longer members of the input focus branch, and PM_CURRENT messages to objects that are members of the new input focus branch. The effect is that non-directed input messages will be sent to the newly designated input object. When a new window is added to PegPresentationManager, that window automatically receives input focus. Likewise, if that window has any child objects, the first child object of the window receives focus. This continues until a leaf node (an object with no children) is found. The Add() function is most commonly used to add child objects to a window. Since the last object added to a window becomes the first child of the window (unless AddToEnd() is used to add the object), the last object added to a window will have input focus when the window is first displayed.
|