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>

When I click on the button the onClick event is not executed.

I had to resort to re-sinking the events I want for the button element
as show below for the event on button to be executed.

<code>
DOM.setEventListener(button.getElement(), new EventListener() {
               public void onBrowserEvent( Event e) {
                   switch(e.getTypeInt()) {
                       case Event.ONCLICK:
                           Window.alert("Clicked Me");
                           break;
                       default:
                           break;
                   }
               }
           });
           DOM.sinkEvents(button.getElement(), Event.ONCLICK);
</code>

Is there a way of constructing a new Widget from a combination of
elements and widgets while preserving the events in the embedded
widgets?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to