Repository: flex-asjs
Updated Branches:
  refs/heads/develop 5ecbcd701 -> 593e4df8f


FLEX-35202 - Add to Label click event
- Remove "selectable" property from Label and make select/unselect abitlity - 
PAYG creating bead: UnselectableElementBead


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/593e4df8
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/593e4df8
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/593e4df8

Branch: refs/heads/develop
Commit: 593e4df8f86a8d0ea9009853e94f368b6474d312
Parents: 5ecbcd7
Author: piotrz <[email protected]>
Authored: Sun Mar 5 12:54:00 2017 +0100
Committer: piotrz <[email protected]>
Committed: Sun Mar 5 12:54:00 2017 +0100

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/html/Label.as | 41 ++++--------
 .../flex/html/beads/UnselectableElementBead.as  | 69 ++++++++++++++++++++
 .../Basic/src/main/resources/basic-manifest.xml |  1 +
 .../Basic/src/main/resources/defaults.css       |  9 +++
 .../src/main/flex/org/apache/flex/html/Label.as | 38 +++--------
 .../flex/html/beads/UnselectableElementBead.as  | 69 ++++++++++++++++++++
 .../HTML/src/main/resources/basic-manifest.xml  |  1 +
 .../HTML/src/main/resources/defaults.css        |  9 +++
 8 files changed, 180 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as
index 21282f8..310c758 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/Label.as
@@ -28,6 +28,16 @@ package org.apache.flex.html
         import org.apache.flex.core.WrappedHTMLElement;
     }
 
+    /**
+     *  Dispatched when the user clicks on a Label.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.8.0
+     */
+    [Event(name="click", type="org.apache.flex.events.MouseEvent")]
+
        /*
         *  Label probably should extend TextField directly,
         *  but the player's APIs for TextLine do not allow
@@ -40,6 +50,7 @@ package org.apache.flex.html
      *  The Label class implements the basic control for labeling
      *  other controls.
      *
+     *  @toplevel
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
@@ -123,7 +134,7 @@ package org.apache.flex.html
          *  @private
          */
                public function set html(value:String):void
-               {
+        {
             COMPILE::SWF
             {
                 ITextModel(model).html = value;
@@ -133,31 +144,8 @@ package org.apache.flex.html
                 this.element.innerHTML = value;
                 this.dispatchEvent('textChange');
             }
-               }
-        private var _selectable:Boolean;
-
-        public function get selectable():Boolean
-        {
-            return _selectable;
-        }
-        public function set selectable(value:Boolean):void
-        {
-            if(value != _selectable)
-            {
-                _selectable = value;
-                COMPILE::JS
-                {
-                    if(element)
-                    {
-                        element.style.cursor = _selectable ? "auto" : 
"default";
-                        element.style.pointerEvents = _selectable ? "auto" : 
"none";
-                    }
-                }
-            }
-
         }
 
-
         /**
          *  @private
          */
@@ -179,11 +167,6 @@ package org.apache.flex.html
             positioner = element;
             element.flexjs_wrapper = this;
             element.style.whiteSpace = "nowrap";
-            if(!selectable)
-            {
-                element.style.cursor = "default";
-                element.style.pointerEvents = "none";
-            }
 
             className = "Label";
             typeNames = "Label";

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
new file mode 100644
index 0000000..c1471cc
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.html.beads
+{
+    import org.apache.flex.core.IBead;
+    import org.apache.flex.core.IUIBase;
+    import org.apache.flex.core.IStrand;
+
+       /**
+        *  UnselectableElement bead prevents from text selection of html 
element
+        *
+        *  @viewbead
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.8
+        */
+       public class UnselectableElementBead implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               public function UnselectableElementBead()
+               {
+               }
+
+        private var _strand:IStrand;
+
+        /**
+                *  @copy org.apache.flex.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+
+                       COMPILE::JS
+                       {
+                               var host:IUIBase = value as IUIBase;
+                               host.element.classList.add("unselectable");
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 0799491..072aed9 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -80,6 +80,7 @@
      <component id="HRuleView" class="org.apache.flex.html.beads.HRuleView" />
      <component id="VRuleView" class="org.apache.flex.html.beads.VRuleView" />
      -->
+    <component id="UnselectableElementBead" 
class="org.apache.flex.html.beads.UnselectableElementBead"/>
     <component id="NumericOnlyTextInputBead" 
class="org.apache.flex.html.accessories.NumericOnlyTextInputBead" />
     <component id="PasswordInputBead" 
class="org.apache.flex.html.accessories.PasswordInputBead" />
     <component id="TextPromptBead" 
class="org.apache.flex.html.accessories.TextPromptBead" />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/Basic/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css 
b/frameworks/projects/Basic/src/main/resources/defaults.css
index 40ed0b5..431c564 100644
--- a/frameworks/projects/Basic/src/main/resources/defaults.css
+++ b/frameworks/projects/Basic/src/main/resources/defaults.css
@@ -34,6 +34,15 @@
     box-sizing: border-box;
 }
 
+.unselectable
+{
+    -moz-user-select: -moz-none;
+    -khtml-user-select: none;
+    -webkit-user-select: none;
+    -o-user-select: none;
+    user-select: none;
+}
+
 Application
 {
        padding: 0px;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as
index ca3d795..8937f28 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/Label.as
@@ -28,6 +28,16 @@ package org.apache.flex.html
         import org.apache.flex.core.WrappedHTMLElement;
     }
 
+    /**
+     *  Dispatched when the user clicks on a Label.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.8.0
+     */
+    [Event(name="click", type="org.apache.flex.events.MouseEvent")]
+
        /*
         *  Label probably should extend TextField directly,
         *  but the player's APIs for TextLine do not allow
@@ -135,29 +145,6 @@ package org.apache.flex.html
                 this.dispatchEvent('textChange');
             }
                }
-        private var _selectable:Boolean;
-
-        public function get selectable():Boolean
-        {
-            return _selectable;
-        }
-        public function set selectable(value:Boolean):void
-        {
-            if(value != _selectable)
-            {
-                _selectable = value;
-                COMPILE::JS
-                {
-                    if(element)
-                    {
-                        element.style.cursor = _selectable ? "auto" : 
"default";
-                        element.style.pointerEvents = _selectable ? "auto" : 
"none";
-                    }
-                }
-            }
-
-        }
-
 
         /**
          *  @private
@@ -180,11 +167,6 @@ package org.apache.flex.html
             positioner = element;
             element.flexjs_wrapper = this;
             element.style.whiteSpace = "nowrap";
-            if(!selectable)
-            {
-                element.style.cursor = "default";
-                element.style.pointerEvents = "none";
-            }
 
             className = "Label";
             typeNames = "Label";

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
new file mode 100644
index 0000000..dd9838a
--- /dev/null
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/UnselectableElementBead.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.html.beads
+{
+    import org.apache.flex.core.IBead;
+    import org.apache.flex.core.IUIBase;
+    import org.apache.flex.core.IStrand;
+
+       /**
+        *  UnselectableElement bead prevents from text selection of html 
element
+        *
+        *  @viewbead
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.8
+        */
+       public class UnselectableElementBead implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               public function UnselectableElementBead()
+               {
+               }
+
+               private var _strand:IStrand;
+               
+               /**
+                *  @copy org.apache.flex.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.8
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+
+                       COMPILE::JS
+                       {
+                               var host:IUIBase = value as IUIBase;
+                               host.element.classList.add("unselectable");
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml 
b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index 4968d95..9e643af 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -96,6 +96,7 @@
      <component id="HRuleView" class="org.apache.flex.html.beads.HRuleView" />
      <component id="VRuleView" class="org.apache.flex.html.beads.VRuleView" />
      -->
+    <component id="UnselectableElementBead" 
class="org.apache.flex.html.beads.UnselectableElementBead"/>
     <component id="DisableBead" class="org.apache.flex.html.beads.DisableBead" 
/>
     <component id="NumericOnlyTextInputBead" 
class="org.apache.flex.html.accessories.NumericOnlyTextInputBead" />
     <component id="PasswordInputBead" 
class="org.apache.flex.html.accessories.PasswordInputBead" />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/593e4df8/frameworks/projects/HTML/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css 
b/frameworks/projects/HTML/src/main/resources/defaults.css
index 21422f3..2951025 100644
--- a/frameworks/projects/HTML/src/main/resources/defaults.css
+++ b/frameworks/projects/HTML/src/main/resources/defaults.css
@@ -34,6 +34,15 @@
        box-sizing: border-box;
 }
 
+.unselectable
+{
+       -moz-user-select: -moz-none;
+       -khtml-user-select: none;
+       -webkit-user-select: none;
+       -o-user-select: none;
+       user-select: none;
+}
+
 Alert
 {
        IBeadModel: 
ClassReference("org.apache.flex.html.beads.models.AlertModel");

Reply via email to