PDA

View Full Version : 2.0-m1 modifying label style on a combobox field messes up the empty field warning



bigmountainben
10 May 2009, 8:26 AM
GWT 1.6, GXT 2.0-m1 (built as of 5/10/09), Hosted mode

When you have a ComboBox field, and:
- you style the label with a margin component
- you set allowBlank to false

The warning image will not appear in the right place (on top of the combo box arrow).

By contrast applying the same formatting to a TextField works fine.

The example code is below- just tab through the two fields, without any input to demonstrate.

public class Test implements EntryPoint {

public void onModuleLoad() {

Window w = new Window();
w.setHeading("my favorite variables");
w.setWidth(500);
w.setAutoHeight(true);
w.setShadow(true);
w.add(new TestForm(w));
w.show();
}

static class TestForm extends LayoutContainer {

Window w;

TestForm(Window w) {
this.w = w;
FormLayout fl = new FormLayout();
fl.setDefaultWidth(300);
fl.setLabelWidth(100);
setLayout(fl);
setAutoHeight(true);
}

@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
// Some fields
TextField foo = new TextField();
foo.setFieldLabel("foo");
foo.setAllowBlank(false);
foo.setLabelStyle("font-size:16px;margin-right:1em");

SimpleComboBox bar = new SimpleComboBox();
bar.setFieldLabel("bar");
bar.setLabelStyle("font-size:16px;margin-right:1em");
bar.add("Foo");
bar.add("Bar");
bar.add("Baz");
bar.add("Quux");
bar.setAllowBlank(false);

add(foo);
add(bar);
}
}

sven
10 May 2009, 8:28 AM
Your post is missing significant details again. In which browser do you ahve the issues?

bigmountainben
10 May 2009, 8:30 AM
Read the first line.

sven
10 May 2009, 8:32 AM
Hostedmode can be safari, IE or firefox ;)

bigmountainben
10 May 2009, 8:36 AM
Safari (MacOS X 10.5.6)

sven
10 May 2009, 8:40 AM
The erroraligning is bound to a bug in the aligning method for browsers using the webkit engine. This will be fixed with the next milestone.

bigmountainben
10 May 2009, 8:47 AM
Thanks Sven!

sven
10 May 2009, 9:40 AM
You should also not use margin-right there. Browsers display margin differently. You can defnie the labelWidth with setLabelWidth