IMO, the better fix would be to just rename the selector in defaults.css to be 
UnselectableElementBead and have UnselectableElementBead add 
"UnselectableElementBead" to the classList.

Or am I not understanding what this does?

-Alex


On 6/2/18, 1:59 PM, "Harbs" <harbs.li...@gmail.com> wrote:

    What I really wanted to do here was create some self invoking code which 
was run when the UnselectableElementBead class was loaded.
    
    Is there any way of doing that without writing a static method and invoking 
that?
    
    Thanks,
    Harbs
    
    
    > On Jun 2, 2018, at 11:39 PM, ha...@apache.org wrote:
    > 
    > This is an automated email from the ASF dual-hosted git repository.
    > 
    > harbs pushed a commit to branch develop
    > in repository 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%40adobe.com%7C9369538a50114755520308d5c8cbb09c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636635699536531937&sdata=iPymBmOQfeD1312Szlsc6Fwc4E5GU2Kj3OwfvmWh%2Bzk%3D&reserved=0
    > 
    > 
    > The following commit(s) were added to refs/heads/develop by this push:
    >     new b157ecf  Removed unselectable selector
    > b157ecf is described below
    > 
    > commit b157ecff5ea11ff2035e105f266b0925c1970005
    > Author: Harbs <ha...@in-tools.com>
    > AuthorDate: Sat Jun 2 23:39:28 2018 +0300
    > 
    >    Removed unselectable selector
    > ---
    > .../projects/Basic/src/main/resources/defaults.css |  9 ---------
    > .../royale/html/beads/UnselectableElementBead.as   | 22 
++++++++++++++++++++++
    > 2 files changed, 22 insertions(+), 9 deletions(-)
    > 
    > diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css 
b/frameworks/projects/Basic/src/main/resources/defaults.css
    > index ea02120..23a324d 100644
    > --- a/frameworks/projects/Basic/src/main/resources/defaults.css
    > +++ b/frameworks/projects/Basic/src/main/resources/defaults.css
    > @@ -26,15 +26,6 @@
    >   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
    > {
    >   IBeadLayout: 
ClassReference("org.apache.royale.html.beads.layouts.VerticalFlexLayout");
    > diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/UnselectableElementBead.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/UnselectableElementBead.as
    > index 6697472..c80c907 100644
    > --- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/UnselectableElementBead.as
    > +++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/UnselectableElementBead.as
    > @@ -34,6 +34,27 @@ package org.apache.royale.html.beads
    >   public class UnselectableElementBead implements IBead
    >   {
    >           /**
    > +          * @royaleignorecoercion HTMLStyleElement
    > +          */
    > +         private static function insertRule():void
    > +         {
    > +                 // only do this once...
    > +                 if(ruleInserted)
    > +                         return;
    > +                 ruleInserted = true;
    > +                 // Inject a new css selector
    > +                 COMPILE::JS
    > +                 {
    > +                         var style:HTMLStyleElement = 
document.createElement('style') as HTMLStyleElement;
    > +                         style.type = 'text/css';
    > +                         style.innerHTML = '.unselectable 
{-moz-user-select: none;-webkit-user-select: none;-ms-user-select: 
none;user-select: none;}';
    > +                         
document.getElementsByTagName('head')[0].appendChild(style);
    > +                 }
    > +
    > +         }
    > +         private static var ruleInserted:Boolean;
    > +
    > +         /**
    >            *  constructor.
    >            *
    >            *  @langversion 3.0
    > @@ -57,6 +78,7 @@ package org.apache.royale.html.beads
    >            */
    >           public function set strand(value:IStrand):void
    >           {
    > +                 insertRule();
    >                   _strand = value;
    > 
    >                   COMPILE::JS
    > 
    > -- 
    > To stop receiving notification emails like this one, please contact
    > ha...@apache.org.
    
    

Reply via email to