diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-7AE34C8A-50C6-49BA-9E43-AE76873B5E12.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-7AE34C8A-50C6-49BA-9E43-AE76873B5E12.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,43 @@ + + + + + +Handling +toolbar item events +

To be able to receive toolbar item events in your application +or application view, you must implement the toolbar observer interface in +the view and register the view to the toolbar:

To receive toolbar item +events, use the observer class MAknToolbarObserver.

The example below shows how to set the toolbar observer.

+ void CMyAppView::ConstructL( TInt aResId ) + { + BaseConstructL( aResId ); + CAknToolbar* toolbar = Toolbar(); + if ( toolbar ) + { + toolbar->SetToolbarObserver( this ); + } + } +
+

Handle toolbar item events in MAknToolbarObserver’s OfferToolbarEventL().

OfferToolbarEventL() is called when the toolbar +item state has changed, for example when a button is pressed. When handling +a toolbar event, the control in question can be identified from the commandid +that is sent as a parameter in the method. The ID belongs to that control +it was sent from (in case of a button, the ID of the button that was pressed).

+

The example below illustrates how to implement OfferToolBarEventL().

+ void CMyAppView::OfferToolbarEventL( TInt aCommandId ) + { + if ( aCommandId == KButtonId ) + { + // do button function + … + } + } +
+
\ No newline at end of file