46
46
47
47
import java .util .ArrayList ;
48
48
import java .util .List ;
49
+ import java .util .function .Predicate ;
50
+ import java .util .function .Supplier ;
49
51
50
52
import static com .sun .javafx .scene .control .inputmap .InputMap .*;
51
53
import static javafx .scene .input .KeyCode .*;
@@ -78,12 +80,19 @@ public ListViewBehavior(ListView<T> control) {
78
80
listViewInputMap = createInputMap ();
79
81
80
82
// add focus traversal mappings
81
- addDefaultMapping (listViewInputMap , FocusTraversalInputMap .getFocusTraversalMappings ());
83
+ Supplier <Boolean > isListViewOfComboBox =
84
+ (Supplier <Boolean >) control .getProperties ().get ("editableComboBox" );
85
+ Predicate <KeyEvent > isInComboBox = e -> isListViewOfComboBox != null ;
86
+ Predicate <KeyEvent > isInEditableComboBox =
87
+ e -> isListViewOfComboBox != null && isListViewOfComboBox .get ();
88
+ if (isListViewOfComboBox == null ) {
89
+ addDefaultMapping (listViewInputMap , FocusTraversalInputMap .getFocusTraversalMappings ());
90
+ }
82
91
addDefaultMapping (listViewInputMap ,
83
- new KeyMapping (HOME , e -> selectFirstRow ()),
84
- new KeyMapping (END , e -> selectLastRow ()),
85
- new KeyMapping (new KeyBinding (HOME ).shift (), e -> selectAllToFirstRow ()),
86
- new KeyMapping (new KeyBinding (END ).shift (), e -> selectAllToLastRow ()),
92
+ new KeyMapping (new KeyBinding ( HOME ) , e -> selectFirstRow (), isInEditableComboBox ),
93
+ new KeyMapping (new KeyBinding ( END ) , e -> selectLastRow (), isInEditableComboBox ),
94
+ new KeyMapping (new KeyBinding (HOME ).shift (), e -> selectAllToFirstRow (), isInComboBox ),
95
+ new KeyMapping (new KeyBinding (END ).shift (), e -> selectAllToLastRow (), isInComboBox ),
87
96
new KeyMapping (new KeyBinding (PAGE_UP ).shift (), e -> selectAllPageUp ()),
88
97
new KeyMapping (new KeyBinding (PAGE_DOWN ).shift (), e -> selectAllPageDown ()),
89
98
@@ -98,9 +107,9 @@ public ListViewBehavior(ListView<T> control) {
98
107
new KeyMapping (F2 , e -> activate ()),
99
108
new KeyMapping (ESCAPE , e -> cancelEdit ()),
100
109
101
- new KeyMapping (new KeyBinding (A ).shortcut (), e -> selectAll ()),
102
- new KeyMapping (new KeyBinding (HOME ).shortcut (), e -> focusFirstRow ()),
103
- new KeyMapping (new KeyBinding (END ).shortcut (), e -> focusLastRow ()),
110
+ new KeyMapping (new KeyBinding (A ).shortcut (), e -> selectAll (), isInComboBox ),
111
+ new KeyMapping (new KeyBinding (HOME ).shortcut (), e -> focusFirstRow (), isInComboBox ),
112
+ new KeyMapping (new KeyBinding (END ).shortcut (), e -> focusLastRow (), isInComboBox ),
104
113
new KeyMapping (new KeyBinding (PAGE_UP ).shortcut (), e -> focusPageUp ()),
105
114
new KeyMapping (new KeyBinding (PAGE_DOWN ).shortcut (), e -> focusPageDown ()),
106
115
@@ -145,10 +154,9 @@ public ListViewBehavior(ListView<T> control) {
145
154
new KeyMapping (new KeyBinding (DOWN ).shortcut ().shift (), e -> discontinuousSelectNextRow ()),
146
155
new KeyMapping (new KeyBinding (PAGE_UP ).shortcut ().shift (), e -> discontinuousSelectPageUp ()),
147
156
new KeyMapping (new KeyBinding (PAGE_DOWN ).shortcut ().shift (), e -> discontinuousSelectPageDown ()),
148
- new KeyMapping (new KeyBinding (HOME ).shortcut ().shift (), e -> discontinuousSelectAllToFirstRow ()),
149
- new KeyMapping (new KeyBinding (END ).shortcut ().shift (), e -> discontinuousSelectAllToLastRow ())
157
+ new KeyMapping (new KeyBinding (HOME ).shortcut ().shift (), e -> discontinuousSelectAllToFirstRow (), isInComboBox ),
158
+ new KeyMapping (new KeyBinding (END ).shortcut ().shift (), e -> discontinuousSelectAllToLastRow (), isInComboBox )
150
159
);
151
-
152
160
addDefaultChildMap (listViewInputMap , verticalListInputMap );
153
161
154
162
// --- horizontal listview
@@ -198,7 +206,6 @@ public ListViewBehavior(ListView<T> control) {
198
206
}
199
207
200
208
201
-
202
209
/***************************************************************************
203
210
* *
204
211
* Implementation of BehaviorBase API *
0 commit comments