I am working on implementing a ListBox that I want to be able to alert the user when they make a selection in the ListBox. Is there a way to respond to the user clicking an item in the listbox, and respond to the selection before a "changeEvent" occurs so I can prevent the changeEvent from getting fired. I have tried using
Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
System.out.println("EVENT: " + event.getTypeInt());
}
});
but this never responds to clicking on a specific element in the ListBox, it only responds to clicking on the ListBox initially, 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!