Symbian3/SDK/Source/GUID-6113CC3B-F994-4AA8-81E9-50433A3266E2.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-6113CC3B-F994-4AA8-81E9-50433A3266E2" xml:lang="en"><title>Adding
and removing toolbar extension items</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The toolbar extension can basically hold the same items as the toolbar
itself. However, the floating toolbar extension can only have focusable buttons.
A fixed toolbar extension does not naturally have focus since its parent toolbar
is not focusing. </p>
<p>The toolbar extension can have a variable number of items. They are located
from the upper left (right in mirrored layout) corner. If all items cannot
fit into the extension, items from the end will be dropped. </p>
<p>You can add items to the toolbar extension in the similar way as to a toolbar,
either by defining <codeph>TBAR_CTRL</codeph> resource structures in the resource
file or adding the items dynamically by using toolbar extension functions.</p>
<p>You can also remove items from the extension.</p>
<p>The example below shows how to add an item to the toolbar extension as
the first item.</p>
<codeblock xml:space="preserve">void CMyAppView::AddItemAsFirstToToolbarExtensionL()
    {
    CAknToolbar* toolbar = Toolbar();
    if ( toolbar )
        {
        CAknToolbarExtension* toolbarExtension = toolbar-&gt;ToolbarExtension();
        if ( toolbarExtension )
            {
            CAknButton* newButton = CAknButton::NewL( R_MYAPP_EXTENSION_BUTTON );
            // Last parameter tells the index at where to add new item
            toolbarExtension-&gt;AddItemL( 
                newButton, EAknCtButton, KExtensionButtonId, 0, 0 );
            }
        }
    }
</codeblock>
<p>The example below shows how to remove an item from the toolbar extension.</p>
<codeblock xml:space="preserve">void CMyAppView::RemoveItemFromToolbarExtensionL()
    {
    CAknToolbar* toolbar = Toolbar();
    if ( toolbar )
        {
        CAknToolbarExtension* toolbarExtension = toolbar-&gt;ToolbarExtension();
        if ( toolbarExtension )
            {
            toolbarExtension-&gt;RemoveItemL( KExtensionButtonId );
            }
        }
    }
</codeblock>
</conbody></concept>