I can't find a remove function too,butESRI Viewer is extandable applicationyou can extend WidgetTemplate.as as you want (this code is just a sample - not tested)
// Viewer version is 2.5
public function addTitlebarButton(btnIcon:String, btnTip:String, btnFunction:Function, selectable:Boolean = true):void
{
var btn:TitlebarButton = new TitlebarButton();
btn.callback = btnFunction;
btn.selectable = selectable;
btn.source = btnIcon;
btn.toolTip = btnTip;
if (selectable)
{
btn.addEventListener(MouseEvent.CLICK, titlebarButton_clickHandler);
if (headerToolGroup.numElements == 0)
{
selectedTitlebarButtonIndex = 0; // automatically select the first button added
}
}
headerToolGroup.addElement(btn);
}
public function removeTitlebarButton(item:TitlebarButton):Boolean
{
var success:Boolean = false;
// next logic is the same as in headerToolGroup.removeElement(...)
if (item != null)
{
try
{
var buttonIndex:int = headerToolGroup.getElementIndex(item);
if (buttonIndex > -1)
{
headerToolGroup.removeElementAt(buttonIndex);
success = true;
}
}
catch (error:ArgumentError) // child element not exists in headerToolGroup
{
trace(error.getStackTrace());
}
}
return success;
}