<?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-270FC83E-1D47-4CF9-A560-FB5DDA53111E" xml:lang="en"><title>Showing
or hiding the toolbar extension</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The toolbar extension is automatically shown when the extension button
is pressed. </p>
<p>The extension button is in a latched down state when the extension is open.
If the extension button is pressed again, the extension closes and the extension
button returns to normal state. This also happens if the user clicks somewhere
outside the extension area. </p>
<p>By default, the extension is left open when the user selects an item from
the extension. You can change this by defining suitable flags to the button.</p>
<p>The example below shown the definition of a toolbar extension with the
button closing the extension when selected.</p>
<codeblock xml:space="preserve">RESOURCE AVKON_TOOLBAR_EXTENSION r_myapp_toolbar_extension
{
items =
{
TBAR_CTRL
{
type = EAknCtButton;
id = ECmdExtFirst;
control = AVKON_BUTTON
{
flags = KAknButtonRequestExitOnButtonUpEvent;
states =
{
AVKON_BUTTON_STATE
{
extension = r_myapp_toolbar_ext_first;
}
};
};
},
…
}
};
}
</codeblock>
<p>You can also show or hide the toolbar extension in your application using
the methods in the class <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknToolbarExtension.html" format="application/java-archive"><codeph>CAknToolbarExtension</codeph></xref>.</p>
<p>The example below shows how to hide or show the toolbar extension.</p>
<codeblock xml:space="preserve">void CMyAppView::ChangeToolbarExtensionVisibility( TBool aHide )
{
CAknToolbar* toolbar = Toolbar();
if ( toolbar )
{
CAknToolbarExtension* toolbarExtension = toolbar->ToolbarExtension();
if ( toolbarExtension )
{
if ( aHide )
{
toolbarExtension->SetShown( EFalse );
}
else
{
toolbarExtension->SetShown( ETrue );
}
}
}
}
</codeblock>
</conbody></concept>