Tuesday, January 22, 2013

Re: How get widget width, after it's drawed ?

Try this method that uses ComputedStyle. I couldn't be bothered to optimize it with deferred binding so it does some runtime checks.

static public native String getComputedStyleProperty(Element el, String property) /*-{
        if (window['getComputedStyle']) { // W3C DOM method
    if (property === 'float')
    property = 'cssFloat';

            var value = el.style[property], computed;

            if (!value) {
                computed = el['ownerDocument']['defaultView']['getComputedStyle'](el, null);
                if (computed) { // test computed before touching for safari
                    value = computed[property];
                }
            }
            return value;

        } else if (el['currentStyle']) {
            var value;

            switch(property) {
                case 'opacity' :// IE opacity uses filter
                    value = 100;
                    try { // will error if no DXImageTransform
                        value = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;

                    } catch(e) {
                        try { // make sure its in the document
                            value = el.filters('alpha').opacity;
                        } catch(err) {
                        }
                    }
                    return value / 100;
                case 'float': // fix reserved word
                    property = 'styleFloat'; // fall through
                default:
                    value = el['currentStyle'] ? el['currentStyle'][property] : null;
                    return ( el.style[property] || value );
            }
        }
        return "";
}-*/;


On Monday, January 21, 2013 10:01:34 AM UTC-5, Michał Zakrzewski wrote:
Thanks for your help, but my problem is still not resolved. Sometimes I have good value, sometimes not...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/lZ3GfyXkx0gJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate