This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 764bb4b  jewel-tabbar: fix AssignTabContent bead when change 
dataprovider (fix #730)
764bb4b is described below

commit 764bb4b3f9a09584cf043aed4d125bb94f0512e9
Author: Carlos Rovira <[email protected]>
AuthorDate: Mon Feb 24 20:02:01 2020 +0100

    jewel-tabbar: fix AssignTabContent bead when change dataprovider (fix #730)
---
 .../beads/controls/tabbar/AssignTabContent.as      | 22 ++++++-------
 .../apache/royale/jewel/beads/views/TabBarView.as  | 37 ++++++++++++----------
 2 files changed, 31 insertions(+), 28 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
index d07a7cd..7fc8b84 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/AssignTabContent.as
@@ -27,7 +27,8 @@ package org.apache.royale.jewel.beads.controls.tabbar
        [DefaultProperty("content")]
 
        /**
-        *  The Disabled bead class is a specialty bead that can be used to 
disable a Jewel control.
+        *  The AssignTabContent bead class is a specialty bead that can be 
used with a TabBar control
+        *  to assign a TabBarContent to the "content" property and bind both 
components to work together.
         *  
         *  @langversion 3.0
         *  @playerversion Flash 10.2
@@ -63,11 +64,14 @@ package org.apache.royale.jewel.beads.controls.tabbar
                public function set strand(value:IStrand):void
                {
                        tabbar = value as TabBar;
-                       tabbar.addEventListener(Event.CHANGE, changeHandler);
-                       tabbar.addEventListener("selectionChanged", 
selectionChangedChangeHandler);
+                       tabbar.addEventListener("selectionChanged", 
selectionChangedHandler);
                        updateHost();
                }
 
+               /**
+                *  This bead adds the content to the tabbar parent, other 
strategies could be done
+                *  extending this bead.
+                */
                protected function updateHost():void
                {
                        if(tabbar)
@@ -78,20 +82,14 @@ package org.apache.royale.jewel.beads.controls.tabbar
                        }
                }
                
-               protected function 
selectionChangedChangeHandler(event:Event):void
+               protected function selectionChangedHandler(event:Event):void
                {
-                       if(content)
+                       if(content && tabbar.selectedIndex != -1)
                        {
                                content.selectedContent = 
tabbar.selectedItem[selectedContentProperty];
                        }
                }
 
-               protected function changeHandler(event:Event):void
-               {
-                       var item:Object = event.target.selectedItem;
-                       content.selectedContent = item[selectedContentProperty];
-               }
-
                private var _content:TabBarContent;
         /**
                 *  The TabBarContent related to the TabBar
@@ -113,7 +111,7 @@ package org.apache.royale.jewel.beads.controls.tabbar
                
                private var _selectedContentProperty:String;
         /**
-                *  the property in the object in the TabBar dataProvider that 
will be used to
+                *  the TabBar dataProvider object's property that will be used 
to
                 *  select the content
                 *
                 *  @langversion 3.0
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
index 116489d..4e84a45 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/TabBarView.as
@@ -67,23 +67,28 @@ package org.apache.royale.jewel.beads.views
                        var ir:TabBarButtonItemRenderer = 
dataGroup.getItemRendererAt(listModel.selectedIndex) as 
TabBarButtonItemRenderer;
                        var selectionBead:ISelectableItemRenderer;
 
-                       if(prev_ir) {
-                               selectionBead = getSelectionRenderBead(prev_ir);
-                               selectionBead.selected = false;
-                               var lastRect:ClientRect = 
prev_ir.getBoundingBox;
-                               var currentRect:ClientRect = ir.getBoundingBox;
-                               var widthDiff:Number = lastRect.width / 
currentRect.width;
-                               if(isNaN(widthDiff))
-                                       widthDiff = 1;
-                               var positionDiff:Number = lastRect.left - 
currentRect.left;
-                               
-                               selectionBead = getSelectionRenderBead(ir);
-                               selectionBead.selected = true;
-                               ir.animateIndicator(positionDiff, widthDiff, 
300, 'ease-in-out');                               
-                       } else
+                       trace("lastSelectedIndex", lastSelectedIndex)
+
+                       if(listModel.selectedIndex != -1)
                        {
-                               selectionBead = getSelectionRenderBead(ir);
-                               selectionBead.selected = true;
+                               if(prev_ir) {
+                                       selectionBead = 
getSelectionRenderBead(prev_ir);
+                                       selectionBead.selected = false;
+                                       var lastRect:ClientRect = 
prev_ir.getBoundingBox;
+                                       var currentRect:ClientRect = 
ir.getBoundingBox;
+                                       var widthDiff:Number = lastRect.width / 
currentRect.width;
+                                       if(isNaN(widthDiff))
+                                               widthDiff = 1;
+                                       var positionDiff:Number = lastRect.left 
- currentRect.left;
+                                       
+                                       selectionBead = 
getSelectionRenderBead(ir);
+                                       selectionBead.selected = true;
+                                       ir.animateIndicator(positionDiff, 
widthDiff, 300, 'ease-in-out');                               
+                               } else
+                               {
+                                       selectionBead = 
getSelectionRenderBead(ir);
+                                       selectionBead.selected = true;
+                               }
                        }
                        
                        lastSelectedIndex = listModel.selectedIndex;

Reply via email to