changeset 6550:e08cbee88d7d

RT-32460: TextArea: Wrong behavior of CTRL-DOWN on Windows
author leifs
date Mon, 24 Mar 2014 18:12:04 -0700
parents 35858482e928
children d21a135c84d5
files modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextAreaSkin.java
diffstat 2 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java	Tue Mar 25 10:04:54 2014 +1300
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java	Mon Mar 24 18:12:04 2014 -0700
@@ -237,9 +237,9 @@
             else if ("SelectNextLine".equals(name)) skin.nextLine(true);
 
             else if ("ParagraphStart".equals(name)) skin.paragraphStart(true, false);
-            else if ("ParagraphEnd".equals(name)) skin.paragraphEnd(true, false);
+            else if ("ParagraphEnd".equals(name)) skin.paragraphEnd(true, isWindows(), false);
             else if ("SelectParagraphStart".equals(name)) skin.paragraphStart(true, true);
-            else if ("SelectParagraphEnd".equals(name)) skin.paragraphEnd(true, true);
+            else if ("SelectParagraphEnd".equals(name)) skin.paragraphEnd(true, isWindows(), true);
 
             else if ("PreviousPage".equals(name)) skin.previousPage(false);
             else if ("NextPage".equals(name)) skin.nextPage(false);
@@ -499,7 +499,7 @@
     protected void mouseTripleClick(HitInfo hit) {
         // select the line
         skin.paragraphStart(false, false);
-        skin.paragraphEnd(false, true);
+        skin.paragraphEnd(false, isWindows(), true);
     }
 
     //    public function mouseWheelMove(e:MouseEvent):Void {
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextAreaSkin.java	Tue Mar 25 10:04:54 2014 +1300
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextAreaSkin.java	Mon Mar 24 18:12:04 2014 -0700
@@ -1312,21 +1312,30 @@
         }
     }
 
-    public void paragraphEnd(boolean nextIfAtEnd, boolean select) {
+    public void paragraphEnd(boolean goPastInitialNewline, boolean goPastTrailingNewline, boolean select) {
         TextArea textArea = getSkinnable();
         String text = textArea.textProperty().getValueSafe();
         int pos = textArea.getCaretPosition();
         int len = text.length();
+        boolean wentPastInitialNewline = false;
 
         if (pos < len) {
-            if (nextIfAtEnd && text.codePointAt(pos) == 0x0a) {
-                // We are at the end of a paragraph.
-                // Move to the next paragraph.
+            if (goPastInitialNewline && text.codePointAt(pos) == 0x0a) {
+                // We are at the end of a paragraph, start by moving to the
+                // next paragraph.
                 pos++;
+                wentPastInitialNewline = true;
             }
-            // Go to the end of this paragraph
-            while (pos < len && text.codePointAt(pos) != 0x0a) {
-                pos++;
+            if (!(goPastTrailingNewline && wentPastInitialNewline)) {
+                // Go to the end of this paragraph
+                while (pos < len && text.codePointAt(pos) != 0x0a) {
+                    pos++;
+                }
+                if (goPastTrailingNewline && pos < len) {
+                    // We are at the end of a paragraph, finish by moving to
+                    // the beginning of the next paragraph (Windows behavior).
+                    pos++;
+                }
             }
             if (select) {
                 textArea.selectPositionCaret(pos);