royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yishay Weiss <yishayj...@hotmail.com>
Subject RE: [royale-asjs] 01/01: First (non-working) version
Date Mon, 13 Nov 2017 13:20:47 GMT
Why not listen to the container’s ‘initComplete’? Also, doesn’t DisableBead work for
containers as is?



________________________________
From: Piotr Zarzycki <piotrzarzycki21@gmail.com>
Sent: Monday, November 13, 2017 3:15:54 PM
To: dev@royale.apache.org
Subject: Re: [royale-asjs] 01/01: First (non-working) version

Harbs,

First thought is register to "initComplete" for each children ? But does
each of our children emit such event ?

Piotr


2017-11-13 14:01 GMT+01:00 Harbs <harbs.lists@gmail.com>:

> I need some help here.
>
> The code should be working, but the bead is added before the children are
> added, so the styles and attributes are not applied.
>
> Any ideas on how to delay the execution until after the full tree of
> children are added?
>
> Thanks,
> Harbs
>
> > On Nov 13, 2017, at 2:57 PM, harbs@apache.org wrote:
> >
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > harbs pushed a commit to branch feature/disable-children-bead
> > in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
> >
> > commit c1cc651a6f03cbcdb6792eed367140404adf7863
> > Author: Harbs <harbs@in-tools.com>
> > AuthorDate: Mon Nov 13 14:57:34 2017 +0200
> >
> >    First (non-working) version
> > ---
> > .../Basic/src/main/resources/basic-manifest.xml    |   1 +
> > .../royale/html/beads/DisableChildrenBead.as       | 152
> +++++++++++++++++++++
> > 2 files changed, 153 insertions(+)
> >
> > diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
> b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
> > index 90b72b3..02a8579 100644
> > --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
> > +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
> > @@ -113,6 +113,7 @@
> >     <component id="UnselectableElementBead"
> class="org.apache.royale.html.beads.UnselectableElementBead"/>
> >     <component id="DisableBead" class="org.apache.royale.html.beads.DisableBead"
> />
> >     <component id="DisabledAlphaBead" class="org.apache.royale.html.beads.DisabledAlphaBead"
> />
> > +    <component id="DisableChildrenBead" class="org.apache.royale.html.beads.DisableChildrenBead"
> />
> >     <component id="NumericOnlyTextInputBead"
> class="org.apache.royale.html.accessories.NumericOnlyTextInputBead" />
> >     <component id="PasswordInputBead" class="org.apache.royale.html.accessories.PasswordInputBead"
> />
> >     <component id="PasswordInputRemovableBead"
> class="org.apache.royale.html.accessories.PasswordInputRemovableBead" />
> > diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/
> royale/html/beads/DisableChildrenBead.as b/frameworks/projects/Basic/
> src/main/royale/org/apache/royale/html/beads/DisableChildrenBead.as
> > new file mode 100644
> > index 0000000..ca4ffa1
> > --- /dev/null
> > +++ b/frameworks/projects/Basic/src/main/royale/org/apache/
> royale/html/beads/DisableChildrenBead.as
> > @@ -0,0 +1,152 @@
> > +///////////////////////////////////////////////////////////
> /////////////////////
> > +//
> > +//  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::SWF {
> > +     import flash.display.DisplayObjectContainer;
> > +     }
> > +
> > +     import org.apache.royale.core.IBead;
> > +     import org.apache.royale.core.IStrand;
> > +     import org.apache.royale.core.IUIBase;
> > +     import org.apache.royale.core.UIHTMLElementWrapper;
> > +     import org.apache.royale.events.Event;
> > +     import org.apache.royale.events.IEventDispatcher;
> > +     import org.apache.royale.events.ValueEvent;
> > +
> > +     COMPILE::JS{
> > +             import org.apache.royale.core.WrappedHTMLElement;
> > +             import org.apache.royale.core.HTMLElementWrapper;
> > +     }
> > +     /**
> > +      *  The DisableBead class is a specialty bead that can be used with
> > +      *  any UIBase. When disabled is true, the bead prevents
> interaction with the component.
> > +      *  The appearance of the component when disabled is controlled by
> a separate bead.
> > +      *
> > +      *  @langversion 3.0
> > +      *  @playerversion Flash 10.2
> > +      *  @playerversion AIR 2.6
> > +      *  @productversion Royale 0.0
> > +      */
> > +     public class DisableChildrenBead implements IBead
> > +     {
> > +             /**
> > +              *  constructor.
> > +              *
> > +              *  @langversion 3.0
> > +              *  @playerversion Flash 10.2
> > +              *  @playerversion AIR 2.6
> > +              *  @productversion Royale 0.0
> > +              */
> > +             public function DisableChildrenBead()
> > +             {
> > +             }
> > +
> > +             private var _strand:IStrand;
> > +             private var _disabled:Boolean;
> > +
> > +             /**
> > +              *  @copy org.apache.royale.core.IBead#strand
> > +              *
> > +              *  @langversion 3.0
> > +              *  @playerversion Flash 10.2
> > +              *  @playerversion AIR 2.6
> > +              *  @productversion Royale 0.0
> > +              *  @royaleignorecoercion HTMLInputElement
> > +              *  @royaleignorecoercion org.apache.royale.core.UIBase;
> > +              */
> > +             public function set strand(value:IStrand):void
> > +             {
> > +                     _strand = value;
> > +                     updateHost();
> > +             }
> > +
> > +             public function get disabled():Boolean
> > +             {
> > +                     return _disabled;
> > +             }
> > +
> > +             /**
> > +              *  @private
> > +              *  @royaleignorecoercion org.apache.royale.core.
> HTMLElementWrapper
> > +              */
> > +             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;
> > +             }
> > +
> > +             COMPILE::JS
> > +             private var _lastTabVal:String;
> > +
> > +             /**
> > +              * @royaleignorecoercion org.apache.royale.core.
> HTMLElementWrapper
> > +              */
> > +             private function updateHost():void
> > +             {
> > +                     if(!_strand)//bail out
> > +                             return;
> > +                     COMPILE::SWF {
> > +                             var interactiveObject:DisplayObjectContainer
> = _strand as DisplayObjectContainer;
> > +                             interactiveObject.mouseChildren =
> !disabled;
> > +                     }
> > +
> > +                     COMPILE::JS {
> > +                             setDecendants((_strand as
> HTMLElementWrapper).element);
> > +                     }
> > +
> > +             }
> > +
> > +             COMPILE::JS
> > +             private function setDecendants(elem:HTMLElement):void
> > +             {
> > +                     elem.style["pointerEvents"] = _disabled ? "none" :
> "";
> > +                     _disabled ? elem.setAttribute("tabindex", "-1") :
> elem.removeAttribute("tabindex");
> > +                     elem = elem.firstChild as HTMLElement;
> > +                     while (elem) {
> > +                             setDecendants(elem);
> > +                             elem = elem.nextSibling as HTMLElement;
> > +                     }
> > +             }
> > +
> > +             private function throwChangeEvent():void
> > +             {
> > +                     if (_strand)
> > +                     {
> > +                             IEventDispatcher(_strand).dispatchEvent(new
> ValueEvent("disabledChange", disabled));
> > +                     }
> > +             }
> > +
> > +
> > +     }
> > +}
> >
> > --
> > To stop receiving notification emails like this one, please contact
> > "commits@royale.apache.org" <commits@royale.apache.org>.
>
>


--

Piotr Zarzycki

Patreon: *https://www.patreon.com/piotrzarzycki
<https://www.patreon.com/piotrzarzycki>*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message