I have several same components that at this stage just perform the same operation.
<g:FocusPanel ui:field="panel">
<g:FocusPanel ui:field="panel2">
<g:FocusPanel ui:field="panel3">
@UiField
FocusPanel panel, panel2, panel3;
@UiHandler("panel")
void handleClick(MouseDownEvent event) {
//...
}
@UiHandler("panel2")
void handleClick2(MouseDownEvent event) {
//...
}
@UiHandler("panel3")
void handleClick3(MouseDownEvent event) {
//...
}
So far so good, but how can I "manually" add a mouse handler inside a loop like within the class constructor:
for (FocusPanel panel : panels) {
panel.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
Window.alert("mouse down");
}
});
}
If I write this in the constructor of the java class, I'm getting NullPointerException at this stage where the handler is added to the panel.
Is there any way that I can add these kind of mouseHandlers in the constructor? Or can elements bound via @UiField only be handlers attached via @UiHandler??
Alternativly, do you know of any workaround of adding the same MouseHandler to a bunch of objects as I'm trying in this example?
--
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/-/Q_YIBPusvUUJ.
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