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

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

Introduction

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

Prototype

public static FocusImpl getFocusImplForWidget() 

Source Link

Document

Returns the focus implementation class for manipulating focusable elements that are naturally focusable in all browsers, such as text boxes.

Usage

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

License:sencha.com license

/**
 * Try to focus this widget.
 */
public void focus() {
    FocusImpl.getFocusImplForWidget().focus(getFocusEl());
}

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

License:sencha.com license

/**
 * Tries to remove focus from the widget.
 */
protected void blur() {
    FocusImpl.getFocusImplForWidget().blur(getFocusEl());
}

From source file:com.sencha.gxt.widget.core.client.form.AdapterField.java

License:sencha.com license

@Override
protected void onFocus(Event event) {
    super.onFocus(event);
    if (widget instanceof Component) {
        ((Component) widget).focus();
    } else {//from w w  w .ja v a  2s. c  o m
        FocusImpl.getFocusImplForWidget().focus(widget.getElement());
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.form.widget.FormFieldWrapper.java

License:Open Source License

public void focusField() {
    if (field != null) {
        FocusImpl.getFocusImplForWidget().focus(field.getElement());
    }
}

From source file:org.unitime.timetable.gwt.client.aria.ClickableHint.java

License:Apache License

@Override
public void setAccessKey(char key) {
    FocusImpl.getFocusImplForWidget().setAccessKey(getElement(), key);
}

From source file:org.waveprotocol.wave.client.common.util.DomHelper.java

License:Apache License

/**
 * Focus the element, if possible//from   www.j a  va2 s.c  o m
 * @param element
 */
public static void focus(Element element) {
    // NOTE(user): This may not work for divs, rather use getFocusImplForPanel
    //               for divs.
    try {
        FocusImpl.getFocusImplForWidget().focus(castToOld(element));
    } catch (Exception e) {
        // Suppress null pointer condition
    }
}

From source file:org.waveprotocol.wave.client.common.util.DomHelper.java

License:Apache License

/**
 * Blur the element, if possible//from w ww . j a v a2 s.  c om
 * @param element
 *
 * NOTE(user): Dan thinks this method should be deprecated, but is not
 *               sure why... Dan, please update once you remember.
 */
public static void blur(Element element) {
    FocusImpl.getFocusImplForWidget().blur(castToOld(element));
}

From source file:org.waveprotocol.wave.client.editor.EditorImpl.java

License:Apache License

/**
 * TODO(user): use content document to set caret, and issue operation
 *
 * TODO(danilatos): This stuff seems out of date...
 *
 * TODO(danilatos): Make this method trivially idempotent
 *
 * {@inheritDoc}//ww w .  j  a va2 s  .  co m
 */
@Override
public void focus(boolean collapsed) {
    if (!isAttached()) {
        EditorStaticDeps.logger.error().log("Shouldn't focus a detached editor");
        return;
    }

    // focus document
    if (isEditing() && content != null) {
        // first, handle DOM focus
        FocusedPointRange<Node> htmlSelection = getHtmlSelection(); // save before focusing.

        // element causes webkit based browsers to automatically scroll the element into view
        // In wave, we want to be in charge of how things move, so we cancel this behaviour
        // here by first recording the scrollTops of all the editor's ancestors, and
        // then resetting them after calling focus.
        Element docElement = getDocumentHtmlElement();
        maybeSaveAncestorScrollPositions(docElement);
        FocusImpl.getFocusImplForWidget().focus(DomHelper.castToOld(docElement));
        maybeRestoreAncestorScrollPositions(docElement);

        // then, handle the case when selection already existed inside the element:
        if (htmlSelection != null) {
            // NOTE(patcoleman): we may have killed it with the DOM focusing above, so restore
            NativeSelectionUtil.set(htmlSelection);

            if (!collapsed) {
                // if we have selection, and we're not forcibly collapsing it, then nothing needs doing.
                return;
            } else {
                // Otherwise, we might need to adjust it if we're collapsing it. So we'll fall through to
                // the manual selection-restore-with-collapse, but first we save what we have anyway.
                EditorStaticDeps.logger.trace().log("Saving...");
                doSaveSelection();
            }
        }

        // finally, make sure selection is correct:
        safelyRestoreSelection(aggressiveSelectionHelper, collapsed);
        scheduleUpdateNotification(true, true, false, false);
    }
}

From source file:rocket.widget.client.FocusWidget.java

License:Apache License

FocusImpl getFocusSupport() {
    return FocusImpl.getFocusImplForWidget();
}