Focus Management
Gadget holders manage the keyboard focus. For a gadget, having the focus means that it can receive a keyboard event. A gadget has the focus when the user clicks on it with the mouse.
Pressing the Tab key moves the focus to the next gadget. Pressing Shift-Tab moves it to the previous gadget. By default, the Tab key moves from one gadget to another first from left to right, then from top to bottom. However, you can specify the order in which the gadgets are given the focus when the Tab key is pressed by defining a focus chain.
This section explains the following:
Defining a Focus Chain
Only the gadgets stored in the same gadget holder can be linked by a focus chain. To define a focus chain, use the following member functions of the
IlvGraphic class:
IlvGraphic::setPreviousFocusGraphic IlvGraphic::setLastFocusGraphic IlvGraphic::setFirstFocusGraphic The name parameter provided in the member functions setNextFocusGraphic and setPreviousFocusGraphic is a symbolic name that must be created from the name of the target gadget. For example, if you want the next object in the focus chain of gadget to be the gadget named “Button”, call:
gadget->setNextFocusGraphic(IlvGetSymbol("Button"));
Setting a Focus Chain Between Gadget Holders
By default, the focus loops back to the first gadget in the chain when the user reaches the last gadget in the focus chain. You can, however, force the focus to another gadget holder that you specify using the following member functions:
Notifying a Change of Focus
When the keyboard focus enters or leaves an
IlvGadget object, its associated gadget holder generates the
IlvKeyboardFocusIn and
IlvKeyboardFocusOut events. These events are sent to the gadget, or to its associated interactor, if any, and are processed by the
handleEvent member function. Then, the virtual member functions
focusIn and
focusOut are called. By default these member functions invoke the Focus In and Focus Out callbacks, respectively. See
Associating a Callback with a Gadget.
Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.