events - Handler on DOM elements in GWT -
i want add handler on buttonelement , have implemented follow. please me in resolving error in code. not want add handler directly on button widget.
button button = new button("click"); element buttonelement = button.getelement(); event.seteventlistener(buttonelement, new eventlistener() { @override public void onbrowserevent(event event) { string string = event.gettype(); if(string.equalsignorecase("click")) { system.out.println("click"); } } }); event.sinkevents(buttonelement, event.onclick);
your code correct, might added widget after sink event. have add widget before sink event. example:
button button=new button("click"); element buttonelement = button.getelement(); rootpanel.get().add(button); event.sinkevents(buttonelement, event.onclick); event.seteventlistener(buttonelement, new eventlistener() { @override public void onbrowserevent(event event) { system.out.println("ok"); if(event.onclick == event.gettypeint()) { window.alert("ok"); system.out.println("click"); } } });
Comments
Post a Comment