Control observers

Each control may have an observer, typically another control, to which it can send events. An observer must:

  • implement the mixin class MCoeControlObserver and

  • be set as the observer for the control (or controls) it is to observe using CCoeControl::SetObserver().

A control may have one observer only, but an observer may observe more than one control.

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

A typical use of an observer is a compound control being the observer for its own components. The components send events to their compound control when they receive user input and the compound control manages the interaction between them. For example a control receiving a TPointerEvent::EButton1Down event sends an MCoeControlObserver::EEventRequestFocus event to its observer. This allows the observer to move focus between its components and to update their appearance.