Thanks Luke, But actually doing that in MyDiv causes a compilation error:
cannot find symbol symbol : method addClickListener(<anonymous com.google.gwt.user.client.ui.ClickListener>) location: class com.dds.gwt.widgets.client.ui.MyDiv Just to be clear, MyButton already has listeners set up using Button's native clicklistener so I just want MyDiv wrapper to pass a listener to MyButton. Thanks, Alanj On Tue, Mar 31, 2009 at 11:34 PM, lukehashj <[email protected]> wrote: > > 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 -~----------~----~----~----~------~----~------~--~---
