Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    setStyleName broken on IconButton

    Hello,

    After installing the SNAPSHOT_v8.3d_2012-10-11/Pro Deployment (built 2012-10-11) build it seems that it is no longer possible to set style on an icon button using the following approach. Is this a bug?

    IconButton btn = new IconButton();
    btn.setTitle("title");
    btn.setTooltip("tooltip");
    btn.setIcon("test.png");
    btn.setHoverWidth(200);
    btn.setStyleName("aspecialclassname");

    thanks

    #2
    The correct attribute to set here should be the base style (via setBaseStyle()).
    baseStyle differs from styleName in that "states" may be applied to the style (for buttons this happens as the user interacts with the button, showing roll over styling, selected styling etc). States are implemented as suffixes.
    See javadoc for more on this attribute

    Regards
    Isomorphic Software

    Comment


      #3
      Hi,

      Thanks for your feedback.

      However, we do not want to alter the base style for that - we have it set already and it is working as we want with our css rules.
      What we want to do, and as it was working before updating to that particular nightly, is set the css class for the entire component.

      Since this was working before and we are using this approach for several areas we would like the old behavior reinstated or at least have some switch to enable it again.

      thanks for understandig

      Comment


        #4
        We're not quite following what your expected behavior here is. setStyleName() and setBaseStyle() are both methods to set the css style name of an entire component. The difference is that "stateful" classes such as buttons use the 'baseStyle' and apply suffixes.

        From your description it sounds like had a use case where you were applying both attributes to the same component and they were both having an effect in conjunction with each other. This isn't expected behavior.
        To clear this up, could you perhaps show us an example component definition, plus your the css style name declarations for the styles you were applying, plus a screenshot of the old vs the new appearance you're getting?

        We'll be happy to help get you the appearance you want, and if we have indeed broken backwards compatibility somehow we'll see what we can do to resolve this - but first we need to see the old and new behavior so we can understand exactly what you're having trouble with.

        Regards
        Isomorphic Software

        Comment


          #5
          Hello,

          I attached a screenshot where you can see it working and not working next to each other. The buttons on the left are fine the ones on the right are not as you can see.

          We did some additional digging and found out that it is working when:
          - first call setDisabled(false) on the IconButton
          - next we do setStyleName

          And it is no longer working when there is no call to setDisabled and only the one to setStyleName.

          The call to setStyleName only seems to have effect when the component has been drawed/created? by the setDisabled call.

          This used to work - maybe it is a bad usage of us I can't tell.
          I rather not do the setDisabled call since it triggers a chain of other calls to create/draw the component right?

          Please advise.
          Attached Files

          Comment


            #6
            This appears to be a usage issue - in short, if you call setBaseStyle() instead of setStyleName() things should just work for you.

            A stateful-canvas (like a Button, or an IconButton) has a concept of a base style, plus suffixes that are applied as the user interacts with the button to provide over, selected, focused etc state-indicators.
            The styleName attribute, rather than being specified by the application developer is derived from this base style by internal code.
            If the attribute "styleName" is explicitly set when the button is initialized it has no effect (and as far as we can tell this has been the case in previous builds as well).

            If the button *has been created* the API "setStyleName()" does appear to work for you. However the reason for it working is that you're basically overriding the built in logic to apply a styleName calculated from a base style.
            Since this doesn't update the baseStyle attribute it means that while this may appear to work, if the user then interacts with the button such that the state changes, you're likely to see your styling disappear.

            As far as we can tell this behavior has not changed and it is likely you were relying on a quirk of the system that was making this appear to work for you previously.

            The right fix seems to be simply to use the baseStyle here.

            If you think we're missing something, we'll need the information already requested (sample CSS, plus runnable code that used to work and now fails) to pursue this further.

            Thanks
            Isomorphic Software

            Comment


              #7
              Thanks, we agree with what you are saying - it makes sense to use the base style path. Thanks for clearing this up!

              Comment

              Working...
              X