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

hugoferreira 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 c114afb334 New bead to auto select the first index of Jewel List
c114afb334 is described below

commit c114afb33410749d38df4551466c9af5dc96e6e4
Author: Hugo Ferreira <[email protected]>
AuthorDate: Thu Mar 2 00:25:14 2023 +0000

    New bead to auto select the first index of Jewel List
    
    Also works with Jewel VirtualList
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |  1 +
 .../controls/list/ListAutoSelectFirstIndex.as      | 71 ++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml 
b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index b5afed4bf5..157c54653a 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -128,6 +128,7 @@
     <component id="TableAlternateRowColor" 
class="org.apache.royale.jewel.beads.controls.table.TableAlternateRowColor"/>
 
     <component id="HorizontalListScroll" 
class="org.apache.royale.jewel.beads.controls.list.HorizontalListScroll"/>
+    <component id="ListAutoSelectFirstIndex" 
class="org.apache.royale.jewel.beads.controls.list.ListAutoSelectFirstIndex"/>
     <component id="VirtualListView" 
class="org.apache.royale.jewel.beads.views.VirtualListView"/>
 
     <component id="ButtonBarModel" 
class="org.apache.royale.jewel.beads.models.ButtonBarModel"/>
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAutoSelectFirstIndex.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAutoSelectFirstIndex.as
new file mode 100644
index 0000000000..c4f015afd6
--- /dev/null
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAutoSelectFirstIndex.as
@@ -0,0 +1,71 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.jewel.beads.controls.list
+{
+       import org.apache.royale.events.Event;
+       import org.apache.royale.core.IBead;
+       import org.apache.royale.core.IStrand;
+       import org.apache.royale.jewel.List;
+       
+       /**
+        *  The ListAutoSelectFirstIndex bead is a specialty bead that can be 
used with
+        *  Jewel List control to auto select the first index after the 
dataProvider is changed
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.11
+        */
+       public class ListAutoSelectFirstIndex implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.11
+                */
+               public function ListAutoSelectFirstIndex()
+               {
+               }
+
+               protected var _strand:List;
+               
+               /**
+                *  @copy org.apache.royale.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.11
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value as List;
+            _strand.addEventListener("dataProviderChanged", 
dataProviderChangedHandler);
+               }
+
+        private function dataProviderChangedHandler(event:Event):void
+        {
+            if (_strand.dataProvider != null && _strand.dataProvider.length > 
0)
+                _strand.selectedIndex = 0;
+        }
+       }
+}
\ No newline at end of file

Reply via email to