All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.gwt.test.internal.patchers.TextBoxImplPatcher Maven / Gradle / Ivy

There is a newer version: 0.63
Show newest version
package com.googlecode.gwt.test.internal.patchers;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.impl.TextBoxImpl;
import com.googlecode.gwt.test.internal.utils.JsoProperties;
import com.googlecode.gwt.test.patchers.PatchClass;
import com.googlecode.gwt.test.patchers.PatchMethod;
import com.googlecode.gwt.test.utils.JavaScriptObjects;

@PatchClass(TextBoxImpl.class)
class TextBoxImplPatcher {

    @PatchMethod
    static int getCursorPos(TextBoxImpl textBoxImpl, Element e) {
        return JavaScriptObjects.getInteger(e, JsoProperties.SELECTION_START);
    }

    @PatchMethod
    static int getSelectionLength(TextBoxImpl textBoxImpl, Element e) {
        int selectionStart = JavaScriptObjects.getInteger(e, JsoProperties.SELECTION_START);
        int selectionEnd = JavaScriptObjects.getInteger(e, JsoProperties.SELECTION_END);
        return selectionEnd - selectionStart;
    }

    @PatchMethod
    static void setSelectionRange(TextBoxImpl textBoxImpl, Element e, int pos, int length) {
        JavaScriptObjects.setProperty(e, JsoProperties.SELECTION_START, pos);
        JavaScriptObjects.setProperty(e, JsoProperties.SELECTION_END, pos + length);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy