ImgButton

Hi,
This a very basic ImgButton with an icon and a text on the right side.
The problem is that the generated html always contains 2 DIVs:

  • the expected one, with a table in it for the right icon and label;
  • and DIV showing a default sc/skins/Enterprise/images/ImgButton/button.png.
    If the real icon is big enough the ‘default img’ may not be visible but it’s always there.
    Am I missing something here? The code is very simple:
ImgButton aButton = new ImgButton();
        aButton.setID("bId");        
        aButton.setSize(24);
        aButton.setShowFocused(false);
        aButton.setShowRollOver(true);
        aButton.setNoDoubleClicks(true);
        aButton.setIcon(myicon24.png);
        aButton.setIconSize(24);
        aButton.setTitle("Test");
        aButton.setShowTitle(true);
        aButton.setAutoFit(true);        
        aButton.setTooltip("A ttip");

Thanks!

One more thing, if i take out:
aButton.setSize(24);
the ‘default/unexpected’ button.png stretches and is visible around the real icon img

What appearance are you trying for?

Pls see the attached img.
These buttons are members on a ToolStrip
At the top is what i want, 2 btns with icons and labels.
At the bottom is what i get if
aButton.setSize(24);
it is NOT present (the default button.png stretches and is visible).
By forcing the size to 24 the ‘default’ img is hidden behind the real icon so this may be considered a work around.
The question is why the default button.png is inserted anyway and if I’m doing anything wrong.

One more q. pls, is it possible to place the label under the icon?

imgbtn.gif

Use a Label, not an ImgButton.

Thanks, not sure, i just replaced a button with a Label but hit diff problems:

  • the click handler is not called anymore
  • I had to user setContents as setTitle has no effect for label
  • the tool tip tends to stay visible until i click outside the label

I may stick with the ImgButton but I think there’s a small bug there that makes the button.png to be always added into the generated html
Thanks.

If you are looking for interactivity but no outline, then you are closer to a Button or ImgButton. Button uses CSS styles by default, based on the setting for baseStyle. You could establish a different style series that has no outline / gradient for the base state. See the skinning guide for further details.

It’s not a bug that an ImgButton actually appears as an image - that’s coming from the default setting for src.

I think it’s not clear for me in case of a ImgButton what’s the diff between setSrc and setIcon.
I was expecting setIcon to override any default image used by the button.
If i do setSrc=“” the default img doesn’t show up anymore but i see some warnings in the console. Can i ignore these warnings?
Thx for your help.

The source is the background image and the icon is the icon. See the docs for further clarifications, or just use the previously suggested approach.

How to show tooltip for ImgButton?

How to show tooltip for ImgButton?

setTooltip(..). You should always consult the Javadocs if you’re looking for any functionality.