Repository: flex-asjs Updated Branches: refs/heads/refactor-sprite d7b86841d -> d99e1a020
Add disable bead Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/7961ff9c Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/7961ff9c Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/7961ff9c Branch: refs/heads/refactor-sprite Commit: 7961ff9c7f3d9bbd721004bbab684dfa3d6a07f7 Parents: 9eaf1d4 Author: yishayw <yishayj...@hotmail.com> Authored: Thu Sep 15 10:05:37 2016 +0300 Committer: yishayw <yishayj...@hotmail.com> Committed: Thu Sep 15 10:05:37 2016 +0300 ---------------------------------------------------------------------- .../org/apache/flex/html/beads/DisableBead.as | 130 +++++++++++++++++++ .../HTML/src/main/resources/basic-manifest.xml | 1 + 2 files changed, 131 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7961ff9c/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DisableBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DisableBead.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DisableBead.as new file mode 100644 index 0000000..d01c889 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DisableBead.as @@ -0,0 +1,130 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::SWF { + import flash.display.InteractiveObject; + } + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.IUIBase; + import org.apache.flex.core.UIHTMLElementWrapper; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.ValueEvent; + + COMPILE::JS{ + import org.apache.flex.core.WrappedHTMLElement; + } + /** + * The DisableBead class is a specialty bead that can be used with + * any TextInput control. The bead places a string into the input field + * when there is no value associated with the text property. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DisableBead implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DisableBead() + { + } + + private var _strand:IStrand; + private var _disabled:Boolean; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion org.apache.flex.core.UIBase; + */ + public function set strand(value:IStrand):void + { + _strand = value; + updateHost(); + } + + public function get disabled():Boolean + { + return _disabled; + } + + /** + * @private + */ + public function set disabled(value:Boolean):void + { + if (value != _disabled) + { + _disabled = value; + updateHost(); + throwChangeEvent(); + } + } + + private function disabledChangeHandler(e:Event):void + { + updateHost(); + } + + private function get host():IUIBase + { + return _strand as IUIBase; + } + + private function updateHost():void + { + COMPILE::SWF { + var interactiveObject:InteractiveObject = (_strand as UIHTMLElementWrapper).$displayObject as InteractiveObject; + interactiveObject.mouseEnabled = !disabled; + } + + COMPILE::JS { + (_strand as Object).element.style.pointerEvents = disabled ? "none" : "auto"; + } + + } + + private function throwChangeEvent():void + { + if (_strand) + { + IEventDispatcher(_strand).dispatchEvent(new ValueEvent("disabledChange", disabled)); + } + } + + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7961ff9c/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 cf90ae7..e9a5878 100644 --- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml @@ -75,6 +75,7 @@ <component id="HRuleView" class="org.apache.flex.html.beads.HRuleView" /> <component id="VRuleView" class="org.apache.flex.html.beads.VRuleView" /> --> + <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" /> <component id="TextPromptBead" class="org.apache.flex.html.accessories.TextPromptBead" />