Example usage for com.google.gwt.user.client.ui FocusWidget addFocusHandler

List of usage examples for com.google.gwt.user.client.ui FocusWidget addFocusHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FocusWidget addFocusHandler.

Prototype

public HandlerRegistration addFocusHandler(FocusHandler handler) 

Source Link

Usage

From source file:org.eclipse.che.ide.ui.WidgetFocusTracker.java

License:Open Source License

/**
 * Add widget to track the focus//from w w w.ja  va  2s  .c  o  m
 *
 * @param widget
 *         the widget to track
 */
public void subscribe(final FocusWidget widget) {
    if (focusStates == null) {
        focusStates = new HashMap<>();
    }

    focusStates.put(widget, false);
    widget.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            focusStates.put(widget, true);
        }
    });

    widget.addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            focusStates.put(widget, false);
        }
    });
}