// 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; }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.