On 15 juil, 22:50, melody <[email protected]> wrote:
> I am trying to create a new Widget from a combination of the Fieldset
> HTML element. I want to add a widget like a Button/or or a FlexTable
> to the fieldset. Is there a way of adding the widget without losing
> the event handlers on the widget. See code below.
>
> FlexTable table = new FlexTable();
> Button button = new Button("Button");
> l.addClickHandler(new ClickHandler() {
> public void onClick(ClickEvent e) {
> Window.alert("Clicked on lable .. ehe..eee");
> }
> });
> table.setWidget(0, 0, new FieldSet("Field Set Test", button));
>
> The class for the Field Set is below:
>
> <code>
> class FieldSet extends Composite {
> FieldSet(String legend, Button button) {
> Element fset = DOM.createFieldSet();
> Element leg = DOM.createLegend();
> leg.setInnerText(legend);
> fset.appendChild(leg);
>
> //add the button's element to the field set
> fset.appendChild(button.getElement());
>
> //set the fieldset as the main element for the composite
> widget
> this.setElement(fset);
> }
> }
> </code>
This doesn't look like a Composite, but rather like a full-fledged
Widget.
> When I click on the button the onClick event is not executed.
Because the button is never "logically attached" (i.e. its onAttach
method isn't ever called).
Have a look at Panel or ComplexPanel (well, or even SimplePanel, or
any other container widget) source code.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---