Handling button events

Use the MCoeControlObserver observer interface to observe button events. Set the button container to be its observer.

For more information on events, see Event handling.

void CMyAppContainer::HandleControlEventL( CCoeControl* aControl, 
                                                  TCoeEvent aEventType ) 
    { 
        switch ( aEventType ) 
            { 

// Button state changed (button was pressed) 

            case EEventStateChanged: 
                … 
                break; 

// Button is pressed for a long time (in case of 
// a KAknButtonReportOnLongPress flagged button) 

            case CAknButton::ELongPressEvent: 
                … 
                break; 

// Button long press ended (in case of 
// a KAknButtonReportOnLongPress flagged button) 

            case CAknButton::ELongPressEndedEvent: 
                … 
                break; 

            default: 
                break; 
            } 
    }