Select to view content in your preferred language

Widget's close and open

2455
8
Jump to solution
04-23-2013 05:47 AM
ShaningYu
Honored Contributor
When I open Widget A, I want to close or minimized Widget B if Widget B is open.  In Widget A, what code I should add?  Thanks.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Shanning,

   Sorry wrong app event in last post:

AppEvent.dispatch(AppEvent.WIDGET_CHANGE_STATE, data);

View solution in original post

0 Kudos
8 Replies
RobertJones2
Regular Contributor
0 Kudos
ShaningYu
Honored Contributor
Thanks for your response.  It does not work for me.  Below is what I did.
1)  In config.xml, I added id = "0" (or "1", "2") for the top three widgets.
2)  In the widget w/ id="2", added the code in the wTemplate_openHandler(event:Event)
     for each (var widgetId:Number in ViewerContainer.getInstance().widgetManager.getAllLoadedWidgetIds()) {
               AppEvent.dispatch(AppEvent.TOC_HIDDEN, widgetId);
        }
     }
I run the debugging.  For id=0 or 1, it went through AppEvent.dispatch(AppEvent.TOC_HIDDEN, widgetId).  But the opened widgets are not minimized.
Could you tell what's wrong in the code? 
Besides, how to get widgetTitle's value?  In config.xml, should it be defined like that for a widget:
title="myWidgetTitle"?
Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shaning Yu,

   Attention to detail... Why did you choose
AppEvent.dispatch(AppEvent.TOC_HIDDEN, widgetId);
when the code example that Robert linked to uses:
AppEvent.dispatch(AppEvent.WIDGET_CLOSE, widgetId);
0 Kudos
ShaningYu
Honored Contributor
Robert:
My purpose is when 1 widget is open, make all others as preload="minimized".  Can this be achieved?  Thanks.
Shaning
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shanning,

   You need to be more specific in your threads question then. You orignally said either or.

        var data:Object =
            {
                id: widgetId,
                state: WidgetStates.WIDGET_MINIMIZED
            };
        AppEvent.dispatch(AppEvent.WIDGET_STATE_CHANGED, data);
0 Kudos
ShaningYu
Honored Contributor
Robert:
tested your code in such a scenario:
1) Open widget with id=0
2) Open widget with id=2; in this widget,
   private function wTemplate_openHandler(event:Event):void {
    for each (var widgetId:Number in ViewerContainer.getInstance().widgetManager.getAllLoadedWidgetIds()) {
     if(widgetId != 2) {
      var data:Object = {
        id: widgetId,
        state: WidgetStates.WIDGET_MINIMIZED
       };
      AppEvent.dispatch(AppEvent.WIDGET_STATE_CHANGED, data);
     }
    }
   }
It should minimize the opened widget with id=0.  But that widget's WidgetStates is still open rather than minimized.  Did I miss something?  Thanks.
Shaning
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shanning,

   Sorry wrong app event in last post:

AppEvent.dispatch(AppEvent.WIDGET_CHANGE_STATE, data);
0 Kudos
ShaningYu
Honored Contributor
Perfect!!!  Thanks!!!
0 Kudos