Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to write compound controls

A compound control needs to implement a number of additional functions to manage its component controls. These functions are described in this section.


Counting and accessing component controls

All compound controls should implement CountComponentControls() and ComponentControl(), because these are used internally within the control framework, for activating and drawing controls.

[Top]


Component layout

Compound controls should manage the layout of their components, by implementing SizeChangedL(). This is called from within the control framework whenever any function is called which changes the size of the control. In SizeChangedL(), the compound control should inquire its own size and set the size and the position of its components accordingly.

[Top]


Keyboard focus

Handling key events in compound controls is more complex than for simple controls because of the task of managing keyboard focus. The control stack examines key-presses to see if they are debug (i.e. global rather than application-specific) keys, or if they are to activate menu commands, then passes them to compound controls or dialogs within the application. But once a compound control receives a key event, it is up to the compound control itself to route the key-press to the appropriate component. The compound control must manage the focus of its own component controls using the SetFocus() and IsFocused() functions. When the compound control receives a key event, it should route it to the component which currently has focus. It should also allow focus to be moved from one component to another, for example using the arrow keys or the pointer.

Note that when a component control gets focus, the user normally expects some visual indication of this, such as a rectangle surrounding the control. The control itself, or the container, must handle the drawing of the focus rectangle: the control framework does not do this for you.