On Jan 3, 5:24 pm, jarrod <[email protected]> wrote:
> Using both "setStyle" and "addStyleNames" isn't a necessity. However,
> in some cases, it is desirable to remove any existing, default styles
> from the widget (in the case of HTML) before adding my own custom
> styles. For this to be effective, I imagine I would have to use
> setStyleName or setStylePrimaryName. However, in addition to the
> primary style, I also have a need to set a few additional styles on
> the widget, and thus the use of addStyleNames for the extra names.
>
> While I probably could get away with passing all of the styles at once
> to setStyleName or setStylePrimaryName, doing so feels like a
> violation of the method's contracts (according to the docs).

It would be a violation of setStylePrimaryName, but clearly not of
setStyleName (on the contrary!)

> The real point at hand is that the dual use of setStyleName and
> addStyleNames is inconsistent between different widget types.

No, if setStyleName is called after addStyleName, it'll result in the
same style name in the end (the one passed to setStyleName), whichever
the widget (even if it has a default/primary style name, as
setStyleName will also clear it).
Use of both addStyleNames and setStylePrimaryName though gives
different results depending on whether the widget already has a
default/primary style name, and I agree this should be changed if it
is easily possible (though it's not worth completely refactoring the
UiBinder just to change this edge-case behavior)

> I don't
> think UI developers should have to think about how to set a style name
> for a widget based on what kind of widget it is.

Yes, but I don't think UI developers should use both "set" and "add"
on the same widget either.

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to