Hi Carlos,

Are you trying to implement this in framework or in your app?



pt., 27 gru 2019 o 13:03 Carlos Rovira <[email protected]> napisaƂ(a):

> Hi Harbs and Alex,
>
> trying an implementation of "inheritWidth" function
>
> public function setInheritWidth(noEvent:Boolean = false):void
> {
> setWidth(NaN);//we need _width = NaN
> COMPILE::JS
> {
> this.positioner.style.width = null;//remove style.width after setWidth sets
> _width to "NaNpx" for JS
> }
> }
>
> results in usage like this:
>
> if(condition) {
> button.width = 200;
> } else {
> button.setInheritWidth();
> }
>
> Two things I don't like from this solution:
>
> 1.- *I loose ternary operato**rs*. I mean expressions like:  *button.width
> = **condition ? 200 : NaN;*
> 2.- *Lose opportunity to do binding in MXML*. I mean expressions like:
>  *button.width
> = "{condition ? 200 : NaN}"*
> 3.- *Duplicating `style.width` instruction*. In setWidth the
> positioner.style.width is set to "NaNpx" then we reach the
> "setInheritWidth" to remove to null. No collateral problems, but just seems
> poor code.
>
> As well the meaning of this solution does not end to satisfy my since we
> are really not inherit the value but setting it to a default value (imposed
> just by JS platform).
>
> As well other option was "*sizeWidthToContent*" that seems to have problems
> 1.- and 2.- (at least, but maybe 3.- too) and be a concrete use case
> solution, I mean, not an API to get a value set, that is what I expect here
> (and suppose other users too).
>
> Thoughts?
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>


-- 

Piotr Zarzycki

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

Reply via email to