public String getSelectedText() {
        int start = getCursorPos();
        if (start < 0) {
            return "";
        }
        int length = getSelectionLength();
        return getText().substring(start, start + length);
    }
Gets the text currently selected within this text box.

@return the selected text, or an empty string if none is selected
stroom-core-client-widget/src/main/java/com/google/gwt/user/client/ui/ValueBoxBase.java