WidgetIDs of UI Components??

2137
7
Jump to solution
10-10-2013 06:15 PM
KevinMathieu
New Contributor II
How do I go about accessing the widgetids of and/or a reference to the UI components such as the Navigation, Overview Map, etc widgets? That is, those widgets that are directly layered over the application interface and not part of a widgetcontainer. I tried using the getAllLoadedWidgetIds() method but that only returns the widgetids for the widgets that are contained within a widgetcontainer proper. I am trying to implement a Preferences widget where my users can hide/show interface components like the Navigation widget, but I can't figure out how to obtain a reference so that I can programmatically  open and close the widget (or maybe set its visibility to true/false as needed). Any help that anyone could provide would be appreciated. Thanks.

Kevin
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Kevin,

   The answer to that question can be found here:

http://forums.arcgis.com/threads/57718-Remove-a-UI-element

View solution in original post

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
Kevin,


   I have answered that one before. Find the info here:

http://forums.arcgis.com/threads/56516-Get-quot-UI-quot-Widget-by-Id-Label

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow these steps as shown in the below graphic:


0 Kudos
KevinMathieu
New Contributor II
Robert,

   Thanks for the info. I updated the widgemanger.mxml getWidgetId function per the information in your post and get the id back now (1001) for the UI widget in question. However, using that as a reference like this has no affect:

AppEvent.dispatch(AppEvent.WIDGET_CLOSE, 1001);

   Should I start another thread for that issue? Please advise. Thanks, I will mark your response as the answer given it answered the original question. 

Kevin
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Kevin,

   The answer to that question can be found here:

http://forums.arcgis.com/threads/57718-Remove-a-UI-element
0 Kudos
KevinMathieu
New Contributor II
Robert,

    Thank you very much for the additional info. I followed the steps in your post and this works for getting the widget closed, but how about reopening it? I tried the code below and it did not work. I also tried dispatching a widget_add event and a widget_change_state event and neither of them worked either. Basically, in my Preferences widget I want to be able to let my users click a checkbox to hide/show the Navigation widget. Any additional help that you might be able to provide would be appreciated. Thanks.

Kevin

var oId:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Navigation",true);
    
var openWidget:Object = {
id: oId,
state: WidgetStates.WIDGET_OPENED
}

AppEvent.dispatch(AppEvent.WIDGET_STATE_CHANGED, openWidget);
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Kevin,

   To open a widget you would use this line.

AppEvent.dispatch(AppEvent.WIDGET_RUN, yourWidgetsID#);
0 Kudos
KevinMathieu
New Contributor II
Robert,


     Thanks for the additional information. I have been playing with this and still cannot get it to work. The code below works fine for the closing of the widget, but the opening still does not work even when I dispatch the WIDGET_RUN event. Do you have any other suggestions? Any additional help that you might be able to provide would be appreciated. Thanks.

Kevin

// Checkbox definition:

<mx:CheckBox id="showZoomSlider" selected="true" click="showZoomSlider_clickHandler(event)" />  

// Checkbox event handler:

protected function showZoomSlider_clickHandler(event:MouseEvent):void
{

if( showZoomSlider.selected )
{

var oId:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Navigation",true);
    

AppEvent.dispatch(AppEvent.WIDGET_RUN, oId);
Alert.show( oId.toString()); //Shows the widgetid of 1000

}
else
{

var cId:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Navigation",true);
var data:Object = {
id: cId,
state: WidgetStates.WIDGET_CLOSED}

AppEvent.dispatch(AppEvent.WIDGET_STATE_CHANGED, data);
     
}

}
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Kevin,

    I don't know if I have evene tried to open a UI widget programatically, but I would assume that is is not supported in the OTB WidgetManager as this is the reason you are unsucessfull. If I find some time to chase that rabbit I will post back.
0 Kudos