#BUGFIX by stefan
class: EditFieldWithCompletion
changed:
#hasKeyboardFocus:
#keyPress:x:y:
Fix bug: While typing the initial characters are selected
and then the selection is deleted when typing additional characters (happens in Windows)
--- a/EditFieldWithCompletion.st Tue Feb 28 14:29:33 2017 +0100
+++ b/EditFieldWithCompletion.st Tue Feb 28 15:54:07 2017 +0100
@@ -218,14 +218,16 @@
gotFocusBoolean ifTrue:[
"position cursor behind of already typed chars"
- self selectAll.
+ "/ SV: disable this code. While typing the initial characters are selected
+ "/ and then the selection is deleted when typing additional characters (happens in Windows)
+"/ self selectAll.
] ifFalse:[
(self hasFocus not and:[optionsWindow notNil and:[optionsWindow hasFocus not]]) ifTrue:[
self unselect.
self hideOptionsWindow.
].
].
- ^ super hasKeyboardFocus:gotFocusBoolean
+ super hasKeyboardFocus:gotFocusBoolean
"Created: / 08-08-2009 / 23:28:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
"Modified: / 09-08-2009 / 10:14:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
@@ -235,9 +237,9 @@
keyPress:key x:x y:y
"Forward certain events to optionsView if any"
- <resource: #keyboard (#CursorDown #CursorUp #Accept #Return #Escape #BackSpace #Delete)>
+ <resource: #keyboard (#CursorDown #CursorUp #CursorLeft #CursorRight #Accept #Return #Escape #BackSpace #Delete)>
- (key isCharacter or:[#(Paste Copy Cut) includesIdentical:key]) ifTrue:[
+ (key isCharacter or:[#(Paste Copy Cut CursorLeft CursorRight) includesIdentical:key]) ifTrue:[
super keyPress:key x:x y:y.
^ self.
].
@@ -253,12 +255,16 @@
key == #Escape ifTrue:[self hideOptionsWindow].
(key == #BackSpace or:[key == #Delete or:[key == #Tab]]) ifTrue:[
super keyPress:key x:x y:y.
+ (list isEmptyOrNil or:[list first isEmptyOrNil]) ifTrue:[
+ "empty editfield: no option window and no completion"
+ self hideOptionsWindow.
+ ^ self.
+ ].
key == #Tab ifTrue:[
self startTabCompletion
] ifFalse:[
self startCompletion.
].
- ^ self.
].