Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Control observers

Each control can optionally have an observer control, to which it can send events. A control is made an observer by deriving it from the mixin class MCoeControlObserver. It must then be set as the observer for the control (or controls) it is to observe, using CCoeControl::SetObserver(). A control may have only one observer, but an observer control may observe more than one control.

MCoeControlObserver defines a set of events that can be sent to a control's observer. These are not the same as user input events, but are typically used to allow a control to inform its container control than an event has occurred that requires the container to do some processing: an example is when a component control wishes to obtain keyboard focus.

A control sends an event to its observer using CCoeControl::ReportEventL(), and the observer receives the event using MCoeControlObserver::HandleControlEventL(), which is implemented in the concrete control observer class. Event types, which are not the same as window server events, are defined by the MCoeControlObserver enum TCoeEvent.

A typical use of observer controls is to make a compound control the observer for its components. The components can send events to their compound control when they receive user input events, and the compound control can manage the interaction between the components. A typical example is that when a control receives a TPointerEvent::EButton1Down event, it sends an MCoeControlObserver::EEventRequestFocus event to its observer. This allows the observer to move focus between its components, and to update their appearance.