Joseph is right: call click() but pay attention on what, this.click() calls the click on the CustomButton instance, btn.click() calls the click on the inner declared Button field. As I say, I don't get having two of them.
Anyway take a look at TextButton and CustomButtn in GWT. I believe they can be easily used to achieve an image+text button.
Probably the quicker way is defining a simple image+text SafeHtmlTemplate and pass it to the Button(SafeHtml) constructor.
Choose you poison :)
On Thursday, July 19, 2012 12:46:38 PM UTC+2, javed ansari wrote:
I have created one CustomButton which consists of once image and one--
label.
public class CustomButton extends Button implements ClickHandler{
// call an empty constructor
public ConfigButton() {
}
private Label conflbl;
private Button btn;
public CustomButton(String imgUrl, String btnText) {
this.parentScreen = parentScreen;
Image img = new Image();
img.setUrl(imgUrl);
img.setSize("20px", "20px");
AbsolutePanel panel = new AbsoultePanel();
panel.add(img, nleft + 110, ntop - 30);
btn = new Button();
btn.setSize("250px", "300px");
conflbl = new Label(btnText);
conflbl.setSize("130", "60");
panel.add(btn, nleft, ntop);
panel.add(conflbl, nleft + 60, ntop + 40);
conflbl.addClickHandler(this);
btn.addClickHandler(this);
}
@Override
public void onClick(ClickEvent event) {
// Handle the label and the button click here.
// Then raise a fresh Click handler. But How???
this.Click() // This is not working
}
}
I want to raise a click event once this button is clicked and
obviously in the OnClick() handler of the CustomButton should receive
Source as the CustomButton (Not as Button). This way our CustomButton
will work truly as a button. I tried calling this.Click() but it is
not raising the event.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/iUJYnTuui7MJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment