allow acceptOnLostFocus.
authorClaus Gittinger <cg@exept.de>
Wed, 11 Dec 1996 17:08:14 +0100
changeset 892 043b0ab4b786
parent 891 d7a8def7efa2
child 893 33d35adb2702
allow acceptOnLostFocus.
EditField.st
--- a/EditField.st	Thu Nov 21 19:59:43 1996 +0100
+++ b/EditField.st	Wed Dec 11 17:08:14 1996 +0100
@@ -15,14 +15,14 @@
 		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
 		lengthLimit entryCompletionBlock passwordCharacter
 		cursorMovementWhenUpdating enableChannel autoScrollHorizontally
-		acceptOnTab'
+		acceptOnTab acceptOnLostFocus'
 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
 		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor'
 	poolDictionaries:''
 	category:'Views-Text'
 !
 
-!EditField  class methodsFor:'documentation'!
+!EditField class methodsFor:'documentation'!
 
 copyright
 "
@@ -517,6 +517,27 @@
                                                                         [exEnd]
 
 
+    like above, but also accept the value, when the focus is changed
+    out of the input field:
+    (see changing model value in inspector)
+                                                                        [exBegin]
+        |top field model|
+
+        model := 'hello world' asValue.
+
+        top := StandardSystemView new.
+        top extent:200@100.
+
+        field := EditField origin:(0.0 @ 0.0) in:top.
+        field width:1.0.
+        field model:model.
+        field acceptOnLostFocus:true.
+
+        top open.
+        model inspect.
+                                                                        [exEnd]
+
+
     two views on the same model (each accepts on return):
                                                                         [exBegin]
         |top1 top2 field1 field2 model|
@@ -741,7 +762,7 @@
 "
 ! !
 
-!EditField  class methodsFor:'defaults'!
+!EditField class methodsFor:'defaults'!
 
 defaultLeaveKeys
     "return the set of keys which are taken as leave-keys.
@@ -800,13 +821,24 @@
 
 acceptOnLeave:aBoolean
     "set/clear the acceptOnLeave flag. The default is false.
-     If true, leaving the box (via return, cursor etc) accepts my 
+     If true, leaving the box (via return, cursor etc.) accepts my 
      string into the valueHolder (if any).
      (actually, the set of keys can be specified with #leaveKeys:)"
 
      acceptOnLeave := aBoolean
 
+    "Modified: 11.12.1996 / 16:47:25 / cg"
+!
+
+acceptOnLostFocus:aBoolean
+    "set/clear the acceptOnLostFocus flag. The default is false.
+     If true, a lost focus (via mouse-pointer motion etc.) accepts my 
+     string into the valueHolder (if any)."
+
+     acceptOnLostFocus := aBoolean
+
     "Modified: 16.12.1995 / 16:26:45 / cg"
+    "Created: 11.12.1996 / 16:48:00 / cg"
 !
 
 acceptOnReturn:aBoolean
@@ -1308,6 +1340,18 @@
     ^ super focusIn
 !
 
+hasKeyboardFocus:aBoolean
+    aBoolean ifFalse:[
+        acceptOnLostFocus ifTrue:[
+            self accept.
+        ].
+    ].
+    super hasKeyboardFocus:aBoolean
+
+    "Created: 11.12.1996 / 16:57:50 / cg"
+    "Modified: 11.12.1996 / 16:58:09 / cg"
+!
+
 keyPress:key x:x y:y
     "if keyHandler is defined, pass input; otherwise check for leave
      keys"
@@ -1749,8 +1793,8 @@
      ].
 ! !
 
-!EditField  class methodsFor:'documentation'!
+!EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.70 1996-10-14 21:29:21 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.71 1996-12-11 16:08:14 cg Exp $'
 ! !