Version: SmartClient Version: 8.2/LGPL Development Only (built 2011-12-05)
Browser: Safari on ipad
I’m having trouble setting the width of ToolStripButtons. I’m developing a SmartGWT application with the iPad as a target platform. Apple recommends toolbar buttons have a hit target area of at least 44x44 pixels, with icons about 20x20 pixels. I have icons that are 24x24 and I’m trying to create a toolbar using these icons for buttons, but with a hit target area of 44 pixels, so I’m trying to set the height and width of the buttons to 44 pixels. Unfortunately, I’m having little success setting the width of ToolStripButtons. Calling setWidth() with an integer parameter to indicate the number of pixels has no effect whatsoever. Calling setWidth() with a string parameter of the form “x%” always seems to set the width of the button to some large size, regardless of the value of x. Calling setHeight() with an integer parameter indicating the number of pixels works perfectly. Is there some trick to the setWidth method? Here is some sample code:
private static final int iconWidth = 24;
private static final int iconHeight = 24;
private static final int buttonHeight = 44;
private static final int buttonWidth = 44;
ToolStrip toolStrip = new ToolStrip();
toolStrip.setWidth100();
toolStrip.setBackgroundColor("#D8D8D8");
ToolStripButton moreOptionsButton = new ToolStripButton();
moreOptionsButton.setIcon("icons/24/moreoptions.png");
moreOptionsButton.setIconHeight(iconHeight);
moreOptionsButton.setIconWidth(iconWidth);
// Setting overflow to HIDDEN has no effect on the result when calling setWidth
moreOptionsButton.setOverflow(Overflow.HIDDEN);
moreOptionsButton.setHeight(buttonHeight); // this works nicely for setting the height
moreOptionsButton.setWidth(buttonWidth); // this has no effect regardless of the value of buttonWidth
// I tried to set the width to 44 pixels by calculating what % 44 pixels is of the visible width of the toolbar;
// regardless of the percent value specified, the button is expanded to its maximum possible size, squeezing any other
// buttons that come after it all the way to the right.
//float buttonSizePercent = ( float )buttonWidth / toolStrip.getVisibleWidth();
//moreOptionsButton.setWidth( String.valueOf(buttonSizePercent * 100) + "%" );
// more buttons added here…
toolStrip.addButton(moreOptionsButton);
toolStrip.draw();
In my real code, the toolstrip is in a VLayout, which is in turn in an HLayout; but the problem occurs regardless of any enclosing objects (e.g. cutting and pasting the sample code I provided into an onModuleLoad routine should demonstrate the problem; you’ll just need an icon file to substitute for ‘moreoptions.png’). Could someone shed some light on the proper way to set the width of ToolStripButtons? I get the same results in IE6 (I know it’s ancient) and Firefox 19.0.2.
I’m using the mobile theme in my gwt.xml file:
<inherits name="com.smartgwt.SmartGwtNoTheme" />
<inherits name="com.smartclient.theme.mobile.Mobile" />
Thanks in advance for any help.
Browser: Safari on ipad
I’m having trouble setting the width of ToolStripButtons. I’m developing a SmartGWT application with the iPad as a target platform. Apple recommends toolbar buttons have a hit target area of at least 44x44 pixels, with icons about 20x20 pixels. I have icons that are 24x24 and I’m trying to create a toolbar using these icons for buttons, but with a hit target area of 44 pixels, so I’m trying to set the height and width of the buttons to 44 pixels. Unfortunately, I’m having little success setting the width of ToolStripButtons. Calling setWidth() with an integer parameter to indicate the number of pixels has no effect whatsoever. Calling setWidth() with a string parameter of the form “x%” always seems to set the width of the button to some large size, regardless of the value of x. Calling setHeight() with an integer parameter indicating the number of pixels works perfectly. Is there some trick to the setWidth method? Here is some sample code:
private static final int iconWidth = 24;
private static final int iconHeight = 24;
private static final int buttonHeight = 44;
private static final int buttonWidth = 44;
ToolStrip toolStrip = new ToolStrip();
toolStrip.setWidth100();
toolStrip.setBackgroundColor("#D8D8D8");
ToolStripButton moreOptionsButton = new ToolStripButton();
moreOptionsButton.setIcon("icons/24/moreoptions.png");
moreOptionsButton.setIconHeight(iconHeight);
moreOptionsButton.setIconWidth(iconWidth);
// Setting overflow to HIDDEN has no effect on the result when calling setWidth
moreOptionsButton.setOverflow(Overflow.HIDDEN);
moreOptionsButton.setHeight(buttonHeight); // this works nicely for setting the height
moreOptionsButton.setWidth(buttonWidth); // this has no effect regardless of the value of buttonWidth
// I tried to set the width to 44 pixels by calculating what % 44 pixels is of the visible width of the toolbar;
// regardless of the percent value specified, the button is expanded to its maximum possible size, squeezing any other
// buttons that come after it all the way to the right.
//float buttonSizePercent = ( float )buttonWidth / toolStrip.getVisibleWidth();
//moreOptionsButton.setWidth( String.valueOf(buttonSizePercent * 100) + "%" );
// more buttons added here…
toolStrip.addButton(moreOptionsButton);
toolStrip.draw();
In my real code, the toolstrip is in a VLayout, which is in turn in an HLayout; but the problem occurs regardless of any enclosing objects (e.g. cutting and pasting the sample code I provided into an onModuleLoad routine should demonstrate the problem; you’ll just need an icon file to substitute for ‘moreoptions.png’). Could someone shed some light on the proper way to set the width of ToolStripButtons? I get the same results in IE6 (I know it’s ancient) and Firefox 19.0.2.
I’m using the mobile theme in my gwt.xml file:
<inherits name="com.smartgwt.SmartGwtNoTheme" />
<inherits name="com.smartclient.theme.mobile.Mobile" />
Thanks in advance for any help.
Comment