Hi Harbs,

My suggestion for adding the selector is to make the selector look like a 
Type/Element Selector with the name "UnselectableElementBead".  If you do that, 
then wouldn't that selector be dropped out if nobody is using 
UnselectableElementBead?

I would hope we could find a solution that doesn't result in code injecting 
styles as that sort of screws up users overriding those styles.

My 2 cents,
-Alex

On 6/4/18, 1:14 AM, "Harbs" <harbs.li...@gmail.com> wrote:

    It does add the style to the class list.
    
    The only question is how to add the selector to the CSS.
    
    Thanks,
    Harbs
    
    > On Jun 4, 2018, at 10:24 AM, Carlos Rovira <carlosrov...@apache.org> 
wrote:
    > 
    > Hi,
    > 
    > I think as Alex that better way for this is the bead add the css style to
    > classList.
    > 
    > thanks
    > 
    > 2018-06-04 6:33 GMT+02:00 Alex Harui <aha...@adobe.com.invalid>:
    > 
    >> 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%7C9369538a50114755520308d5c8cb
    >> b09c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
    >> 7C636635699536531937&sdata=iPymBmOQfeD1312Szlsc6Fwc4E5GU2
    >> Kj3OwfvmWh%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.
    >> 
    >> 
    >> 
    >> 
    > 
    > 
    > -- 
    > Carlos Rovira
    > 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0bd6353a12104f5326d708d5c9f332c7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636636968773528501&sdata=v8vk8mHKjoAN3D0lexy3vhXcOWVeYYc1HDouygyKoE8%3D&reserved=0
    
    

Reply via email to