It sounds like you want to implement the SourcesClickEvents class.

Just implement that class, in your implementation just use
button.addClickListener().

Of course, you'll need to bump the button out of your constructor and
into scope.

-luke

On Mar 31, 12:59 pm, alanj <[email protected]> wrote:
> Hi, I'm new to java & gwt, so please be gentle :-)
>
> I'm wrapping a MyButton widget, which extends Button,  inside another
> widget MyDiv which extends FlowPanel, to control styles etc. So:
>
> public class MyDiv extends FlowPanel {
>         public MyDiv(){
>                 super();
>                 setStyle();
>                 MyButton  button = new MyButton();
>                 this.add(button);
>         }
>         public MyDiv(String html) {
>                 super();
>                 setStyle();
>                 MyButton button = new MyButton(html);
>                 this.add(button);
>         }
>         private void setStyle(){
>                 addStyleName("button");
>         }
> etc.}
>
> Can I within this MyDiv class create an addClickListener(ClickListener
> listener) method -  native to Button but not to FlowPanel -  which
> simply passes a received listener over to the MyButton widget which
> can use it? So from somewhere else:
>
> newButton = new MyDiv("click me");
> newButton.addClickListener(new ClickListener(){
>                         public void onClick(Widget widget) {
>                                //do something on click
>                         }});
>
>  gives
> <div class=myDiv><input type=button value="click me"></div> which does
> something on click
>
> Thanks in advance!
>
> Alanj
--~--~---------~--~----~------------~-------~--~----~
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