You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/09/08 21:57:24 UTC
svn commit: r812664 -
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
Author: tvolkert
Date: Tue Sep 8 19:57:24 2009
New Revision: 812664
URL: http://svn.apache.org/viewvc?rev=812664&view=rev
Log:
PIVOT-268 :: Make TerraTextInputSkin not consume LEFT and RIGHT arrow key presses when the caret is at the left or right of the text input, respectively
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=812664&r1=812663&r2=812664&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Tue Sep 8 19:57:24 2009
@@ -1086,6 +1086,8 @@
if (keyCode == Keyboard.KeyCode.DELETE
|| keyCode == Keyboard.KeyCode.BACKSPACE) {
+ consumed = true;
+
Direction direction = (keyCode == Keyboard.KeyCode.DELETE ?
Direction.FORWARD : Direction.BACKWARD);
@@ -1118,9 +1120,9 @@
} else {
textInput.delete(direction);
}
-
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.LEFT) {
+ consumed = true;
+
int selectionStart = textInput.getSelectionStart();
int selectionLength = textInput.getSelectionLength();
@@ -1143,18 +1145,21 @@
} else {
// Clear the selection and move the caret back by one
// character
- if (selectionLength == 0
- && selectionStart > 0) {
- selectionStart--;
+ if (selectionLength == 0) {
+ if (selectionStart > 0) {
+ selectionStart--;
+ } else {
+ consumed = false;
+ }
}
selectionLength = 0;
}
textInput.setSelection(selectionStart, selectionLength);
-
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.RIGHT) {
+ consumed = true;
+
int selectionStart = textInput.getSelectionStart();
int selectionLength = textInput.getSelectionLength();
@@ -1177,52 +1182,57 @@
// character
selectionStart += selectionLength;
- if (selectionLength == 0
- && selectionStart < textNode.getCharacterCount()) {
- selectionStart++;
+ if (selectionLength == 0) {
+ if (selectionStart < textNode.getCharacterCount()) {
+ selectionStart++;
+ } else {
+ consumed = false;
+ }
}
selectionLength = 0;
}
textInput.setSelection(selectionStart, selectionLength);
-
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.HOME) {
+ consumed = true;
+
// Move the caret to the beginning of the text
textInput.setSelection(0, 0);
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.END) {
+ consumed = true;
+
// Move the caret to the end of the text
textInput.setSelection(textNode.getCharacterCount(), 0);
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.A
&& Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+ consumed = true;
+
// Select all
textInput.setSelection(0, textNode.getCharacterCount());
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.X
&& Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+ consumed = true;
+
if (textInput.isPassword()) {
ApplicationContext.beep();
} else {
textInput.cut();
}
-
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.C
&& Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
+ consumed = true;
+
if (textInput.isPassword()) {
ApplicationContext.beep();
} else {
textInput.copy();
}
-
- consumed = true;
} else if (keyCode == Keyboard.KeyCode.V
&& Keyboard.isPressed(Keyboard.Modifier.CTRL)) {
- textInput.paste();
consumed = true;
+
+ textInput.paste();
} else {
consumed = super.keyPressed(component, keyCode, keyLocation);
}