PDA

View Full Version : Events.BrowserEvent for LayoutContainer



msajdak
11 Aug 2010, 4:41 PM
Hi,
i have some problem i created class:

public class MyClass extends LayoutContainer {
public CellContainer(ArrayList<String> cellList) {
this.addListener(Events.BrowserEvent , new Listener< ContainerEvent>() {
@Override
public void handleEvent(ContainerEvent be) {
// i want it to run when somebody click at the MyClass object
}
});
...
probably i need to add something like
addEventsSunk(Event.MOUSEEVENTS);, but unfortunately i didn't found where should I add it.

Thanks for any help!

sven
12 Aug 2010, 2:13 AM
addListener(Events.OnClick, new Listener< ContainerEvent>() {
@Override
public void handleEvent(ContainerEvent be) {
// i want it to run when somebody click at the MyClass object
}
});
sinkEvents(Event.ONCLICK);

msajdak
12 Aug 2010, 2:55 PM
thanks!

almost works ;)
in my case i need to replace
ContainerEvent with
ComponentEventso working code :


addListener(Events.OnClick, new Listener< ComponentEvent>() {
@Override
public void handleEvent(ComponentEvent be) {
//123
}
});
sinkEvents(Event.ONCLICK);
unfortunatelly it also was executed when i clicked at the children element i solved this problem adding :


sinkEvents(Event.ONCLICK);
addListener(Events.OnClick, new Listener< ComponentEvent>() {
@Override
public void handleEvent(ComponentEvent be) {
be.getEvent().stopPropagation();
}
});
at every child component, please let me know if you know simpler way

sven
13 Aug 2010, 1:26 AM
instead of stop the event bubbling, simple check the target element.