#BUGFIX by cg
class: EditField
comment/format in: #onKey:leaveWith:
changed: #keyPress:x:y:
care for raw-leave keys as well
--- a/EditField.st Sat Aug 04 14:54:21 2018 +0200
+++ b/EditField.st Thu Aug 09 10:29:58 2018 +0200
@@ -1178,12 +1178,14 @@
!
onKey:aKey leaveWith:aBlock
- "arrange for aKey to leave the field and evalaute aBlock.
+ "arrange for aKey to leave the field and evaluate aBlock.
On leave, the precedence of actions is:
1) explicit leaveAction per key
2) general leaveAction
3) tab or return action
- Can be used to arrange for cursorDown to pass focus to another widget."
+ Can be used to arrange for cursorDown to pass focus to another widget,
+ or to override builtin ctrl- shortcuts.
+ The leave-action block will be called with 0,1 (the key) or 2 (self + key) arguments"
leaveKeys := leaveKeys asOrderedCollection.
leaveKeys add:aKey.
@@ -1191,6 +1193,8 @@
leaveKeyActions := Dictionary new.
].
leaveKeyActions at:aKey put:aBlock.
+
+ "Modified (comment): / 09-08-2018 / 09:15:29 / Claus Gittinger"
!
readOnly:aBoolean
@@ -1668,7 +1672,7 @@
#DeleteLine #GotoLine #EndOfLine #EndOfText
#CursorDown #CursorUp)>
- |leave doAccept keyAction numArgs|
+ |rawKey leave doAccept keyAction numArgs|
enabled ifFalse:[
^ self
@@ -1694,7 +1698,9 @@
keyAction := crAction.
].
- leave := leaveKeys includes:key.
+ rawKey := (WindowGroup lastEvent) rawKey.
+
+ leave := (leaveKeys includes:key) or:[leaveKeys includes:rawKey].
leave ifTrue:[
leaveKey := key.
doAccept := doAccept ? acceptOnLeave.
@@ -1704,7 +1710,12 @@
"/ 2) general leaveAction
"/ 3) tab or return action
leaveKeyActions notNil ifTrue:[
- keyAction := leaveKeyActions at:key ifAbsent:[keyAction].
+ keyAction := leaveKeyActions
+ at:key
+ ifAbsent:[
+ leaveKeyActions
+ at:rawKey
+ ifAbsent:keyAction].
].
keyAction := keyAction ? leaveAction.
].
@@ -1774,6 +1785,7 @@
"Modified: / 27-09-2017 / 15:34:19 / cg"
"Modified: / 18-04-2018 / 11:47:58 / stefan"
+ "Modified: / 09-08-2018 / 09:29:52 / Claus Gittinger"
!
keyboardZoom:largerBoolean