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;
}
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);
}
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;
}