@Override
public void ready(final YuiContext Y) {
final Console console = Y.newConsole().render().cast();
Widget button1 = Y.newButton(
ButtonConfig.create().label("button1")
).render(parent);
//using "normal" yuigwt infrastructure
button1.on(new String[]{"click", "mouseover"}, new EventCallback<ButtonEvent>() {
@Override
public void call(ButtonEvent e) {
console.log("1 "+e.type()+" at X="+e.domEvent().clientX());
}
});
Widget button2 = Y.newButton(
ButtonConfig.create().label("button2")
).render(parent);
//using util.Callback generic callback definition
button2.on("click", new Callback() {
@Override
public void call(JsArrayMixed args) {
ButtonEvent e = args.getObject(0).cast();
console.log("2 clicked at X="+e.domEvent().clientX());
}
});
Widget button3 = Y.newButton(
ButtonConfig.create().label("button3")
).render(parent);
//creating a native javascript function
JsFunction fn = new JsFunctionBuilder() {
@Override
public native final JsFunction buildFunction()/*-{
return function(e) {
$wnd.alert("3 "+e.type+" at: "+e.domEvent.clientX);
}
}-*/;
}.buildFunction();
button3.on(new String[]{"mouseover", "mouseout"}, fn);
}
});
}