Reputation: 2481
I have a DataGrid with a column containing TextInputCell. When I focus on this cell a button must become active. In order to do this I have to catch some focus event.
TextInputCell API contains onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater)
. Great, I could catch any event with this, I thought. But the first problem I ran at is that onBrowseEvent is thrown many times in a row when I loose/get focus.
It seems that this problem is typical, but I couldn't either come to or find any solution to solve this. I'd appreciate any help with it.
Here is where I'm going to catch "focus" event:
MyTextInputCell cell = new MyTextInputCell() {
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
//Event handling is expected to be here
}
};
Upvotes: 0
Views: 911
Reputation: 1701
I would recommend adding a cell preview handler and then check the event type against the constants defined in BrowserEvents
Upvotes: 0
Reputation: 122026
Something like this ??
String eventType = event.getType();
if ("focus".equals(eventType)) {
// dosomething
}
Upvotes: 1