changeset 1452:7e06dda995b5

Fixed RT-20845: TextField with bidirectional binding is not editable in applet but editable in standalone execution mode
author leifs
date Mon, 16 Jul 2012 18:57:33 +0200
parents 5ba93f3d48b7
children a6dd0e5c4451
files javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java	Mon Jul 16 11:57:46 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java	Mon Jul 16 18:57:33 2012 +0200
@@ -216,7 +216,7 @@
 //                + character.length() > textInput.getMaximumLength()) {
 //                // TODO Beep?
 //            } else {
-                undoManager.addChange(start, textInput.getText().substring(start, end), character, true);
+                undoManager.addChange(start, textInput.textProperty().getValueSafe().substring(start, end), character, true);
                 replaceText(start, end, character);
 //            }
 
@@ -294,10 +294,12 @@
     private void cut() {
         TextInputControl textInputControl = getControl();
         IndexRange selection = textInputControl.getSelection();
-        int start = selection.getStart();
-        int end = selection.getEnd();
 
-        undoManager.addChange(start, textInputControl.getText().substring(start, end), null);
+        if (selection.getLength() > 0) {
+            int start = selection.getStart();
+            int end = selection.getEnd();
+            undoManager.addChange(start, textInputControl.getText().substring(start, end), null);
+        }
         textInputControl.cut();
     }
 
@@ -306,13 +308,13 @@
         IndexRange selection = textInputControl.getSelection();
         int start = selection.getStart();
         int end = selection.getEnd();
-        String text = textInputControl.getText();
+        String text = textInputControl.textProperty().getValueSafe();
         String deleted = text.substring(start, end);
         int tail = text.length() - end;
 
         textInputControl.paste();
 
-        text = textInputControl.getText();
+        text = textInputControl.textProperty().getValueSafe();
         undoManager.addChange(start, deleted, text.substring(start, text.length() - tail));
     }