Example usage for com.google.gwt.user.client.ui.impl FocusImpl getFocusImplForPanel

List of usage examples for com.google.gwt.user.client.ui.impl FocusImpl getFocusImplForPanel

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui.impl FocusImpl getFocusImplForPanel.

Prototype

public static FocusImpl getFocusImplForPanel() 

Source Link

Document

Returns the focus implementation class for creating and manipulating focusable elements that aren't naturally focusable in all browsers, such as DIVs.

Usage

From source file:com.gwt.components.client.Canvas.java

License:Open Source License

public Canvas(int width, int height) {
    setElement(DOM.createDiv());/*from w  w w .  java 2s. com*/
    sinkEvents(Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONMOUSEWHEEL);
    canvas = DOM.createElement("canvas");
    setWidth(width);
    setHeight(height);
    DOM.appendChild(getElement(), canvas);
    setStyleName("gwt-Canvas");
    Element focusable = FocusImpl.getFocusImplForPanel().createFocusable();
    DOM.appendChild(getElement(), focusable);

    init();

    setFillStyle("black");
    setStrokeStyle("black");
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.suggestionfield.menu.SuggestionsContainer.java

License:Apache License

public SuggestionsContainer(CubaSuggestionFieldWidget suggestionFieldWidget) {
    this.suggestionFieldWidget = suggestionFieldWidget;
    container = DOM.createDiv();//from  ww  w  .  j a  v  a  2  s . c o m

    final Element outer = FocusImpl.getFocusImplForPanel().createFocusable();
    DOM.appendChild(outer, container);
    setElement(outer);

    sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONFOCUS
            | Event.ONKEYDOWN);
    addDomHandler(event -> selectItem(null), BlurEvent.getType());

    setStylePrimaryName(STYLENAME);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.suggestionfield.menu.SuggestionsContainer.java

License:Apache License

protected void performItemCommand(final SuggestionItem item) {
    selectedSuggestion = item;/*from   w  ww  .  ja  va  2 s .  c om*/

    Scheduler.ScheduledCommand cmd = item.getScheduledCommand();
    if (cmd != null) {
        FocusImpl.getFocusImplForPanel().blur(getElement());

        Scheduler.get().scheduleFinally(cmd);
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.verticalmenu.FocusableFlowPanel.java

License:Apache License

protected void setFocus(boolean focus) {
    if (focus) {/*from w  ww. jav  a 2 s  .  c  om*/
        FocusImpl.getFocusImplForPanel().focus(getElement());
    } else {
        FocusImpl.getFocusImplForPanel().blur(getElement());
    }
}

From source file:com.sencha.gxt.widget.core.client.menu.Menu.java

License:sencha.com license

/**
 * Hides this menu and optionally all parent menus
 *
 * @param deep true to close all parent menus
 *//*from   w  ww. j av  a 2 s . c o m*/
public void hide(final boolean deep) {
    if (showing) {
        if (fireCancellableEvent(new BeforeHideEvent())) {

            if (activeItem != null) {
                activeItem.deactivate();
                activeItem = null;
            }

            onHide();

            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    RootPanel.get().remove(Menu.this);
                    // if document.activeElement is null or the body element, focus on onHideFocusElement
                    if (onHideFocusElement != null && (XDOM.getActiveElement() == null || XElement
                            .as(XDOM.getActiveElement()).isOrHasChild(XElement.as(Document.get().getBody())) // IE8 sets activeElement to HTML
                    )) {
                        // EXTGWT-4175: for touch we don't want to focus on the input every time we hide - keyboard will pop up
                        if (!GXT.isTouch()) {
                            FocusImpl.getFocusImplForPanel().focus(onHideFocusElement);
                        }
                    }
                }
            });

            eventPreview.remove();
            showing = false;
            hidden = true;
            fireEvent(new HideEvent());
            if (deep && parentItem != null && parentItem.getParent() instanceof Menu) {
                ((Menu) parentItem.getParent()).hide(true);
            }

        }
    }
}

From source file:com.vaadin.addon.calendar.gwt.client.ui.schedule.FocusableComplexPanel.java

/**
 * Sets/Removes the keyboard focus to the panel.
 * //from   w  w w .  j a  v  a  2 s .  com
 * @param focus
 *            If set to true then the focus is moved to the panel, if set to
 *            false the focus is removed
 */
public void setFocus(boolean focus) {
    if (focus) {
        FocusImpl.getFocusImplForPanel().focus(getElement());
    } else {
        FocusImpl.getFocusImplForPanel().blur(getElement());
    }
}

From source file:com.vaadin.client.ui.FocusableScrollPanel.java

License:Apache License

@Override
public void setFocus(boolean focus) {
    if (useFakeFocusElement()) {
        if (focus) {
            FocusImpl.getFocusImplForPanel().focus(focusElement);
        } else {//from  ww w  .j av a  2  s . c o  m
            FocusImpl.getFocusImplForPanel().blur(focusElement);
        }
    } else {
        super.setFocus(focus);
    }
}

From source file:com.vaadin.client.ui.FocusElementPanel.java

License:Apache License

@Override
public void setFocus(boolean focus) {
    if (focus) {// www . ja v a  2  s.com
        FocusImpl.getFocusImplForPanel().focus(focusElement);
    } else {
        FocusImpl.getFocusImplForPanel().blur(focusElement);
    }
}

From source file:com.vaadin.client.ui.SimpleFocusablePanel.java

License:Apache License

public void setFocus(boolean focus) {
    if (focus) {// w w  w . ja v  a  2s.  c  o m
        FocusImpl.getFocusImplForPanel().focus(getElement());
    } else {
        FocusImpl.getFocusImplForPanel().blur(getElement());
    }
}

From source file:com.vaadin.terminal.gwt.client.ui.FocusableScrollPanel.java

License:Open Source License

@Override
public void setFocus(boolean focus) {
    if (useFakeFocusElement()) {
        if (focus) {
            FocusImpl.getFocusImplForPanel().focus((Element) focusElement.cast());
        } else {//from  ww  w . j a  v  a2s . c  om
            FocusImpl.getFocusImplForPanel().blur((Element) focusElement.cast());
        }
    } else {
        super.setFocus(focus);
    }
}