Search in sources :

Example 1 with CharSpan

use of org.apache.pivot.text.CharSpan in project pivot by apache.

the class TextPaneSkin method mouseClick.

@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    boolean consumed = super.mouseClick(component, button, x, y, count);
    TextPane textPane = (TextPane) component;
    Document document = textPane.getDocument();
    if (button == Mouse.Button.LEFT) {
        int index = getInsertionPoint(x, y);
        if (index != -1) {
            if (count == 2) {
                CharSpan charSpan = CharUtils.selectWord(getRowCharacters(document, index), index);
                if (charSpan != null) {
                    textPane.setSelection(charSpan);
                }
            } else if (count == 3) {
                textPane.setSelection(getRowOffset(document, index), getRowLength(document, index));
            }
        }
    }
    return consumed;
}
Also used : TextPane(org.apache.pivot.wtk.TextPane) CharSpan(org.apache.pivot.text.CharSpan) Document(org.apache.pivot.wtk.text.Document)

Example 2 with CharSpan

use of org.apache.pivot.text.CharSpan in project pivot by apache.

the class TerraTextInputSkin method mouseClick.

@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    if (button == Mouse.Button.LEFT && count > 1) {
        TextInput textInput = (TextInput) getComponent();
        if (count == 2) {
            CharSpan charSpan = CharUtils.selectWord(textInput.getCharacters(), getInsertionPoint(x));
            if (charSpan != null) {
                textInput.setSelection(charSpan);
            }
        } else if (count == 3) {
            textInput.selectAll();
        }
        selectDirection = null;
    }
    return super.mouseClick(component, button, x, y, count);
}
Also used : CharSpan(org.apache.pivot.text.CharSpan) TextInput(org.apache.pivot.wtk.TextInput)

Example 3 with CharSpan

use of org.apache.pivot.text.CharSpan in project pivot by apache.

the class TextAreaSkin method mouseClick.

@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    boolean consumed = super.mouseClick(component, button, x, y, count);
    TextArea textArea = (TextArea) component;
    if (button == Mouse.Button.LEFT) {
        int index = getInsertionPoint(x, y);
        if (index != -1) {
            if (count == 2) {
                CharSpan charSpan = CharUtils.selectWord(textArea.getRowCharacters(index), index);
                if (charSpan != null) {
                    textArea.setSelection(charSpan);
                }
            } else if (count == 3) {
                textArea.setSelection(textArea.getRowOffset(index), textArea.getRowLength(index));
            }
        }
    }
    return consumed;
}
Also used : TextArea(org.apache.pivot.wtk.TextArea) CharSpan(org.apache.pivot.text.CharSpan)

Aggregations

CharSpan (org.apache.pivot.text.CharSpan)3 TextArea (org.apache.pivot.wtk.TextArea)1 TextInput (org.apache.pivot.wtk.TextInput)1 TextPane (org.apache.pivot.wtk.TextPane)1 Document (org.apache.pivot.wtk.text.Document)1