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, [email protected] wrote:
> 
> This is an automated email from the ASF dual-hosted git repository.
> 
> harbs 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 b157ecf  Removed unselectable selector
> b157ecf is described below
> 
> commit b157ecff5ea11ff2035e105f266b0925c1970005
> Author: Harbs <[email protected]>
> 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
> [email protected].

Reply via email to