You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/10/27 16:11:31 UTC
svn commit: r830225 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: TextArea.java
skin/TextAreaSkin.java
Author: gbrown
Date: Tue Oct 27 15:11:31 2009
New Revision: 830225
URL: http://svn.apache.org/viewvc?rev=830225&view=rev
Log:
Selection updates to TextArea.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java?rev=830225&r1=830224&r2=830225&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Tue Oct 27 15:11:31 2009
@@ -482,7 +482,7 @@
}
// Set the selection start to the character following the insertion
- setSelection(selectionStart + text.length(), selectionLength);
+ setSelection(selectionStart + text.length(), 0);
}
public void insertImage(Image image) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=830225&r1=830224&r2=830225&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Tue Oct 27 15:11:31 2009
@@ -857,7 +857,9 @@
NodeView firstNodeView = row.nodeViews.get(0);
NodeView lastNodeView = row.nodeViews.get(row.nodeViews.getLength() - 1);
- if (offset >= firstNodeView.getOffset()
+ if (offset == getCharacterCount() - 1) {
+ rowIndex = n - 1;
+ } else if (offset >= firstNodeView.getOffset()
&& offset < lastNodeView.getOffset() + lastNodeView.getCharacterCount()) {
rowIndex = i;
break;
@@ -1691,6 +1693,7 @@
if (button == Mouse.Button.LEFT) {
// Move the caret to the insertion point
+ // TODO If SHIFT is pressed, select the range
int offset = getInsertionPoint(x, y);
if (offset != -1) {
textArea.setSelection(offset, 0);
@@ -1815,12 +1818,19 @@
consumed = true;
} else if (keyCode == Keyboard.KeyCode.UP) {
- int offset = getNextInsertionPoint(caretX, textArea.getSelectionStart(),
- Direction.BACKWARD);
+ int selectionStart = textArea.getSelectionStart();
+ int offset = getNextInsertionPoint(caretX, selectionStart, Direction.BACKWARD);
if (offset != -1) {
- // TODO Modify selection based on SHIFT key
- textArea.setSelection(offset, 0);
+ int selectionLength;
+ if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ int selectionEnd = selectionStart + textArea.getSelectionLength() - 1;
+ selectionLength = selectionEnd - offset + 1;
+ } else {
+ selectionLength = 0;
+ }
+
+ textArea.setSelection(offset, selectionLength);
Bounds characterBounds = getCharacterBounds(offset);
component.scrollAreaToVisible(0, characterBounds.y, characterBounds.width,
@@ -1829,12 +1839,20 @@
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.DOWN) {
- int offset = getNextInsertionPoint(caretX, textArea.getSelectionStart(),
- Direction.FORWARD);
+ int selectionStart = textArea.getSelectionStart();
+ int offset = getNextInsertionPoint(caretX, selectionStart
+ + textArea.getSelectionLength(), Direction.FORWARD);
if (offset != -1) {
- // TODO Modify selection based on SHIFT key
- textArea.setSelection(offset, 0);
+ int selectionLength;
+ if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
+ selectionLength = offset - selectionStart;
+ } else {
+ selectionStart = offset;
+ selectionLength = 0;
+ }
+
+ textArea.setSelection(selectionStart, selectionLength);
Bounds characterBounds = getCharacterBounds(offset);
component.scrollAreaToVisible(0, characterBounds.y, characterBounds.width,