FlexViewer优化之HeaderControlWidget和Widget开关闭

FlexViewer是个非常优秀的ArcGIS地图开发框架,但其中有些地方如果作部分调整,功能上或者交互上会有很大提升。本此主要修改HeaderControlWidget打开和关闭Widget的功能,以及Widget打开和关闭的功能优化。

 

 

在FlexViewer2.4、FlexViewer2.5,、FlexViewer3.0中,HeaderControlWidget中只能打开Widget,并不能关闭打开的Widget。

=================HeaderControlWidget中Widget的打开与关闭==============

做如下修改,即可实现HeaderControlWidget中Widget的打开与关闭:

1)修改HeaderControllerWidget.mxml中的widgetItemDG_widgetItemClickHandler(event:Event)方法。

 

private function widgetItemDG_widgetItemClickHandler(event:Event):void

            {

                var widgetItem:WidgetItem = ItemRenderer(event.target).data as WidgetItem;

                if (widgetItem.isGroup)

                {

                    groupWidgetArrCol = new ArrayCollection();

                    // check the array of widgets if they are open before hand

                    for each (var widgetObj:Object in widgetItem.widgets)

                    {

                        var widgetItem1:WidgetItem = new WidgetItem;

                        widgetItem1.id = widgetObj.widget.id;

                        widgetItem1.label = widgetObj.widget.label;

                        widgetItem1.icon = widgetObj.widget.icon;

                        widgetItem1.url = widgetObj.widget.url;

                        widgetItem1.open = widgetObj.open;

 

                        groupWidgetArrCol.addItem(widgetItem1);

                    }

                    menuToolTip.visible = false;

                    widgetList.visible = true;

                }

                else

                {

             if (!widgetItem.open)

            {

                AppEvent.dispatch(AppEvent.WIDGET_RUN, widgetItem.id);

            }        

           else

           {

          AppEvent.dispatch(AppEvent.WIDGET_CLOSE, widgetItem.id);

           }

                }

            }

2)修改WidgetItemDataGroupRenderer.mxml中的

 private function itemrenderer_clickHandler(event:MouseEvent):void

   {

      if (!WidgetItem(data).open)

         {

           moveEffect.end();

            moveEffect.play();

         }

else{

dispatchEvent(new Event(WIDGET_ITEM_CLICK, true));

}

  }

 

 

=======================Widget中图片按钮的打开与关闭功能====================

1)修改WidgetTemplateSkin.mxml

    <mx:Image id="icon"

              x.minimized="10" x.open="-20" y="12" y.minimized="-2" width="40" height="40"

              buttonMode="true"

          useHandCursor="true"

              source="{hostComponent.widgetIcon}"

              visible="{hostComponent.enableIcon}"

              visible.closed="false">

        <mx:filters>

            <mx:DropShadowFilter blurX="10" blurY="10"/>

        </mx:filters>

    </mx:Image>

 

2)修改WidgetTemplate.as

    protected function icon_clickHandler(event:MouseEvent):void

    {

        if (_baseWidget)

        {

       if (_baseWidget.getState()== WIDGET_OPENED)

        {

       minimize_clickHandler(event);

       return;

        }

       else if (_baseWidget.getState()== WIDGET_MINIMIZED)

        {

            _baseWidget.setState(WIDGET_OPENED);

        this.widgetFrame.toolTip = "";

        this.icon.toolTip = "";

}

        }

    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值