I am working on a ListBox implementation that I want to alert the user when they make a selection in the ListBox. Is there a way to respond to the user by clicking an item in the list and answer the selection before “changeEvent” occurs, so that I can prevent changeEvent from changing. I tried using
Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
System.out.println("EVENT: " + event.getTypeInt());
}
});
but it never responds to clicking on a specific item in a ListBox, it only responds to clicking on a ListBox when you focus the ListBox. I want to be able to do something like:
Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
if(event is changeEvent && event source is listBox) {
if(do some check here)
event.stopPropagation();
}
}
});
Any suggestions would be greatly appreciated, thanks!
source
share