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

gregdove 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 69d886b60d Tuning to selection logic in Datagrid and AdvancedDataGrid. 
Also, avoid duplicating selectable getter/setter from ListBase.
69d886b60d is described below

commit 69d886b60d70b0e2c5fc5029668fe26aa04ad167
Author: greg-dove <[email protected]>
AuthorDate: Tue Jun 21 17:14:43 2022 +1200

    Tuning to selection logic in Datagrid and AdvancedDataGrid.
    Also, avoid duplicating selectable getter/setter from ListBase.
---
 .../mx/controls/listClasses/AdvancedListBase.as    | 45 +++-----------------
 .../mx/controls/listClasses/DataGridListBase.as    | 49 ++++------------------
 2 files changed, 13 insertions(+), 81 deletions(-)

diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/AdvancedListBase.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/AdvancedListBase.as
index a00d33244e..c33328054f 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/AdvancedListBase.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/AdvancedListBase.as
@@ -2503,56 +2503,21 @@ public class AdvancedListBase extends ListBase 
implements IFocusManagerComponent
      */
     //public var menuSelectionMode:Boolean = false;
 
-    //----------------------------------
-    //  selectable
-    //----------------------------------
 
-    /**
-     *  @private
-     *  Storage for the selectable property.
-     */
-    private var _selectable:Boolean = true;
-
-    [Inspectable(defaultValue="true")]
-
-    /**
-     *  A flag that indicates whether the list shows selected items
-     *  as selected.
-     *  If <code>true</code>, the control supports selection.
-     *
-     *  @default true
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.4
-     */
-    override public function get selectable():Boolean
-    {
-        return _selectable;
-    }
 
     /**
      *  @private
      */
-    override public function set selectable(value:Boolean):void
-    {
-        _selectable = value;
-    }
-
-    /**
-     *  @private
-     *  @royaleignorecoercion org.apache.royale.core.ISelectionModel
-     */
     override public function set selectedIndex(value:int):void
     {   
         if (collection)
             value = Math.min(collection.length - 1, value);
-        clearSelected();
                if (allowMultipleSelection)
-                       commitSelectedIndices([value]);
-               else
-               super.selectedIndex = value;
+                       commitSelectedIndices(value>=0? [value]:[]);
+               else {
+            clearSelected();
+            super.selectedIndex = value;
+        }
     }
     
     //----------------------------------
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataGridListBase.as
 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataGridListBase.as
index f8db1d6fa7..9de031e3e3 100644
--- 
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataGridListBase.as
+++ 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataGridListBase.as
@@ -2549,53 +2549,19 @@ public class DataGridListBase extends ListBase /* 
extends UIComponent
      */
     //public var menuSelectionMode:Boolean = false;
 
-    //----------------------------------
-    //  selectable
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the selectable property.
-     */
-    private var _selectable:Boolean = true;
-
-    [Inspectable(defaultValue="true")]
-
-    /**
-     *  A flag that indicates whether the list shows selected items
-     *  as selected.
-     *  If <code>true</code>, the control supports selection.
-     *
-     *  @default true
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 9
-     *  @playerversion AIR 1.1
-     *  @productversion Royale 0.9.4
-     */
-    override public function get selectable():Boolean
-    {
-        return _selectable;
-    }
-
     /**
      *  @private
      */
-    override public function set selectable(value:Boolean):void
-    {
-        _selectable = value;
-    }
-
-    /**
-     *  @private
-     *  @royaleignorecoercion org.apache.royale.core.ISelectionModel
-     */
     override public function set selectedIndex(value:int):void
     {   
         if (collection)
             value = Math.min(collection.length - 1, value);
-        clearSelected();
-        super.selectedIndex = value;
+        if (allowMultipleSelection) {
+            commitSelectedIndices(value>=0? [value]:[])
+        } else {
+            clearSelected();
+            super.selectedIndex = value;
+        }
     }
     
     //----------------------------------
@@ -5513,6 +5479,7 @@ public class DataGridListBase extends ListBase /* extends 
UIComponent
             indices.shift();
 
             var data:Object = collectionIterator.current;
+            addSelectionData(itemToUID(data), new ListBaseSelectionData(data, 
index, false));
             if (firstTime)
             {
                 (model as ISelectionModel).selectedIndex = index; 
//_selectedIndex = index;
@@ -5523,7 +5490,7 @@ public class DataGridListBase extends ListBase /* extends 
UIComponent
                                anchorBookmark = collectionIterator.bookmark;
                 firstTime = false;
             }
-            addSelectionData(itemToUID(data), new ListBaseSelectionData(data, 
index, false));
+            //addSelectionData(itemToUID(data), new 
ListBaseSelectionData(data, index, false));
             // trace("uid = " + itemToUID(data));
         }
 

Reply via email to