changeset 1067:8e3d6d0bf984

Embedded: Add menu item "Select" to context menu for text controls.
author leifs
date Fri, 18 May 2012 15:00:30 -0700
parents 5869b7d7eb0f
children 827c6ae0d1e1
files javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextInputControlSkin.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/resources/controls.properties
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java	Fri May 18 13:26:55 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TextInputControlBehavior.java	Fri May 18 15:00:30 2012 -0700
@@ -136,6 +136,7 @@
             else if ("NextWord".equals(name)) nextWord();
             else if ("SelectPreviousWord".equals(name)) selectPreviousWord();
             else if ("SelectNextWord".equals(name)) selectNextWord();
+            else if ("SelectWord".equals(name)) selectWord();
             else if ("SelectAll".equals(name)) textInputControl.selectAll();
             else if ("Home".equals(name)) textInputControl.home();
             else if ("End".equals(name)) textInputControl.end();
@@ -323,6 +324,16 @@
         }
     }
 
+    protected void selectWord() {
+        final TextInputControl textInputControl = getControl();
+        textInputControl.previousWord();
+        if (isWindows()) {
+            textInputControl.selectNextWord();
+        } else {
+            textInputControl.selectEndOfNextWord();
+        }
+    }
+
     protected void previousWord() {
         getControl().previousWord();
     }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextInputControlSkin.java	Fri May 18 13:26:55 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextInputControlSkin.java	Fri May 18 15:00:30 2012 -0700
@@ -372,10 +372,11 @@
             final MenuItem copyMI   = new ContextMenuItem("Copy");
             final MenuItem pasteMI  = new ContextMenuItem("Paste");
             final MenuItem deleteMI = new ContextMenuItem("DeleteSelection");
-            final MenuItem selectMI = new ContextMenuItem("SelectAll");
+            final MenuItem selectWordMI = new ContextMenuItem("SelectWord");
+            final MenuItem selectAllMI = new ContextMenuItem("SelectAll");
 
             final ContextMenu cm = new ContextMenu(undoMI, redoMI, cutMI, copyMI, pasteMI, deleteMI,
-                                                   new SeparatorMenuItem(), selectMI);
+                                                   new SeparatorMenuItem(), selectAllMI);
 
             if (PlatformUtil.isEmbedded()) {
                 cm.getStyleClass().add("text-input-context-menu");
@@ -395,7 +396,10 @@
                         if (Clipboard.getSystemClipboard().hasString()) {
                             items.add(pasteMI);
                         }
-                        items.add(selectMI);
+                        if (!hasSelection) {
+                            items.add(selectWordMI);
+                        }
+                        items.add(selectAllMI);
                     } else {
                         undoMI.setDisable(!getBehavior().canUndo());
                         redoMI.setDisable(!getBehavior().canRedo());
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/resources/controls.properties	Fri May 18 13:26:55 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/resources/controls.properties	Fri May 18 15:00:30 2012 -0700
@@ -20,6 +20,7 @@
 TextInputControl.menu.Paste=Paste
 TextInputControl.menu.DeleteSelection=Delete
 TextInputControl.menu.SelectAll=Select All
+TextInputControl.menu.SelectWord=Select
 
 # Virtual Keyboard for embedded FX. This will not be localized for FX 2.2.
 #