You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2020/03/23 22:22:46 UTC

[royale-asjs] branch develop updated: basic: add SetFocus bead to allow components to get focus using the bindable enableFocus property. This bead could be enhanced to remove focus when enableFocus is turn to false

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 91036b3  basic: add SetFocus bead to allow components to get focus using the bindable enableFocus property. This bead could be enhanced to remove focus when enableFocus is turn to false
91036b3 is described below

commit 91036b3335538a27c63e225987bb2dc792ca62af
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Mon Mar 23 23:22:42 2020 +0100

    basic: add SetFocus bead to allow components to get focus using the bindable enableFocus property. This bead could be enhanced to remove focus when enableFocus is turn to false
---
 .../Basic/src/main/resources/basic-manifest.xml    |  1 +
 .../projects/Basic/src/main/royale/BasicClasses.as |  3 +-
 .../org/apache/royale/html/beads/SetFocus.as       | 97 ++++++++++++++++++++++
 3 files changed, 99 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 7f898e4..40e9b43 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -145,6 +145,7 @@
     <component id="AccordionItemRenderer" class="org.apache.royale.html.supportClasses.AccordionItemRenderer"/>
     <component id="AccordionCollapseBead" class="org.apache.royale.html.beads.AccordionCollapseBead"/>
     <component id="DispatchInputFinishedBead" class="org.apache.royale.html.beads.DispatchInputFinishedBead"/>
+    <component id="SetFocus" class="org.apache.royale.html.beads.SetFocus"/>
     <component id="DispatchKeyboardEventBead" class="org.apache.royale.html.beads.DispatchKeyboardEventBead"/>
     <component id="TreeItemRenderer" class="org.apache.royale.html.supportClasses.TreeItemRenderer"/>
     <component id="TreeXMLItemRenderer" class="org.apache.royale.html.supportClasses.TreeXMLItemRenderer"/>
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index 6cb3eb7..482bce6 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -37,8 +37,7 @@ internal class BasicClasses
     import org.apache.royale.html.ToolTip; ToolTip;
 	import org.apache.royale.html.accessories.NumericOnlyTextInputBead; NumericOnlyTextInputBead;
     import org.apache.royale.html.accessories.RestrictTextInputBead; RestrictTextInputBead;
-    import org.apache.royale.html.beads.DispatchInputFinishedBead; DispatchInputFinishedBead;
-	import org.apache.royale.html.accessories.PasswordInputBead; PasswordInputBead;
+    import org.apache.royale.html.accessories.PasswordInputBead; PasswordInputBead;
 	import org.apache.royale.html.accessories.PasswordInputRemovableBead; PasswordInputRemovableBead;
 	import org.apache.royale.html.accessories.TextPromptBead; TextPromptBead;
 	import org.apache.royale.html.beads.AbsolutePositioningViewBeadBase; AbsolutePositioningViewBeadBase;
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/SetFocus.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/SetFocus.as
new file mode 100644
index 0000000..d104a26
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/SetFocus.as
@@ -0,0 +1,97 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.beads
+{
+	COMPILE::JS
+	{
+	import org.apache.royale.core.UIBase;
+	}
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IStrand;
+
+	/**
+	 *  The SetFocus class allows any component to set focus.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.7
+	 */
+	public class SetFocus implements IBead
+	{
+		/**
+		 *  constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.7
+		 */
+		public function SetFocus()
+		{
+		}
+
+		private var _strand:IStrand;
+		
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.7
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			if(_enableFocus)
+				setFocus();
+		}
+
+		/**
+		 * perform the set focus on the _strand
+		 */
+		public function setFocus():void
+		{
+			COMPILE::JS
+			{
+			UIBase(_strand).element.focus();
+			}
+		}
+
+		private var _enableFocus:Boolean;
+		/**
+		 *  if true sets the focus on the _strand
+		 */
+		[Bindable("enableFocusChanged")]
+		public function get enableFocus():Boolean
+		{
+			return _enableFocus;
+		}
+		public function set enableFocus(value:Boolean):void
+		{
+			if(_enableFocus != value)
+			{
+				_enableFocus = value;
+				if(_enableFocus)
+					setFocus();
+			}
+		}
+	}
+}