PDA

View Full Version : How to make a LabelField clickable ?



MartinElkjaer
26 Nov 2008, 3:44 AM
Hi,

Any suggestions on how to make a LabelField clickable inside a form ?

Best regards
Martin

kolli
26 Nov 2008, 5:50 AM
A way of doing that is to add the event "onclick" to the DOM events list of the labelField and then add a listener that can take care of the clicks

An example would be .

LabelField l = new LabelField("ravikanth kolli");
l.addListener(Events.OnClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
System.out.println("kolli");
}
});
rootPanel.add(l);
l.el().addEventsSunk(Event.ONCLICK);

MartinElkjaer
27 Nov 2008, 6:10 AM
Hi,

Thanks for your suggestion, but I cannot make it work.

The method el() return null ?? I tried to call the layout method on the container before calling el(), without success :(

Any idea ??


-Martin






A way of doing that is to add the event "onclick" to the DOM events list of the labelField and then add a listener that can take care of the clicks

An example would be .

LabelField l = new LabelField("ravikanth kolli");
l.addListener(Events.OnClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
System.out.println("kolli");
}
});
rootPanel.add(l);
l.el().addEventsSunk(Event.ONCLICK);

kolli
1 Dec 2008, 5:41 AM
l.el().addEventsSunk(Event.ONCLICK); should be added after the widget is rendered, else el returns null for that widget. As shown in the example, if it doesnot work can you post a part of your code.