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/23 18:01:43 UTC

svn commit: r829112 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Author: gbrown
Date: Fri Oct 23 16:01:43 2009
New Revision: 829112

URL: http://svn.apache.org/viewvc?rev=829112&view=rev
Log:
Fix a couple minor bounds check issues in TextArea.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

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=829112&r1=829111&r2=829112&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 Fri Oct 23 16:01:43 2009
@@ -226,6 +226,7 @@
 
         public abstract NodeView getNext();
         public abstract int getInsertionPoint(int x, int y);
+        // public abstract int getInsertionPoint(int x, int offset, int direction);
         public abstract Bounds getCharacterBounds(int offset);
 
         @Override
@@ -1313,7 +1314,7 @@
                         selectionStart += selectionLength;
 
                         if (selectionLength == 0
-                            && selectionStart < document.getCharacterCount()) {
+                            && selectionStart < document.getCharacterCount() - 1) {
                             selectionStart++;
                         }
 
@@ -1329,24 +1330,28 @@
                     // TODO Use getInsertionPoint(int, int, Direction) to determine the next index
                     int offset = documentView.getInsertionPoint(caretX, caret.y - 5);
 
-                    // TODO Modify selection based on SHIFT key
-                    textArea.setSelection(offset, 0);
+                    if (offset != -1) {
+                        // TODO Modify selection based on SHIFT key
+                        textArea.setSelection(offset, 0);
 
-                    Bounds characterBounds = getCharacterBounds(offset);
-                    component.scrollAreaToVisible(0, characterBounds.y, getWidth(), characterBounds.height);
+                        Bounds characterBounds = getCharacterBounds(offset);
+                        component.scrollAreaToVisible(0, characterBounds.y, getWidth(), characterBounds.height);
 
-                    consumed = true;
+                        consumed = true;
+                    }
                 } else if (keyCode == Keyboard.KeyCode.DOWN) {
                     // TODO Use getInsertionPoint(int, int, Direction) to determine the next index
                     int offset = documentView.getInsertionPoint(caretX, caret.y + caret.height + 1);
 
-                    // TODO Modify selection based on SHIFT key
-                    textArea.setSelection(offset, 0);
+                    if (offset != -1) {
+                        // TODO Modify selection based on SHIFT key
+                        textArea.setSelection(offset, 0);
 
-                    Bounds characterBounds = getCharacterBounds(offset);
-                    component.scrollAreaToVisible(0, characterBounds.y, getWidth(), characterBounds.height);
+                        Bounds characterBounds = getCharacterBounds(offset);
+                        component.scrollAreaToVisible(0, characterBounds.y, getWidth(), characterBounds.height);
 
-                    consumed = true;
+                        consumed = true;
+                    }
                 } else if (Keyboard.isPressed(commandModifier)) {
                     if (keyCode == Keyboard.KeyCode.A) {
                         textArea.setSelection(0, document.getCharacterCount());