Example usage for com.google.gwt.dom.client Range selectNodeContents

List of usage examples for com.google.gwt.dom.client Range selectNodeContents

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Range selectNodeContents.

Prototype

public final native void selectNodeContents(Node referenceNode) ;

Source Link

Document

Sets the Range to contain the contents of a Node.

Usage

From source file:org.rstudio.core.client.dom.impl.DomUtilsStandardImpl.java

License:Open Source License

public void focus(Element element, boolean alwaysDriveSelection) {
    ElementEx el = (ElementEx) element;//ww w .  ja v a 2  s  .c  o  m

    el.focus();
    if (alwaysDriveSelection
            || (el.getContentEditable() && (el.getInnerText() == null || el.getInnerText() == ""))) {
        Document doc = el.getOwnerDocument();
        Range range = Range.create(doc);
        range.selectNodeContents(el);
        Selection sel = Selection.get(NativeWindow.get(doc));
        sel.setRange(range);
    }

    NativeWindow.get().focus();
}