neu: acceptIfUnchanged
authorca
Wed, 26 Jan 2000 15:36:34 +0100
changeset 2105 364c74512645
parent 2104 6ca8e039298f
child 2106 40b0e35b3dbc
neu: acceptIfUnchanged
EditField.st
--- a/EditField.st	Wed Jan 19 17:00:53 2000 +0100
+++ b/EditField.st	Wed Jan 26 15:36:34 2000 +0100
@@ -16,7 +16,7 @@
 		lengthLimit entryCompletionBlock entryCompletionCharacter
 		passwordCharacter cursorMovementWhenUpdating
 		autoScrollHorizontally acceptOnTab acceptOnLostFocus
-		acceptOnPointerLeave'
+		acceptOnPointerLeave acceptIfUnchanged'
 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
 		DefaultSelectionForegroundColor DefaultSelectionBackgroundColor'
 	poolDictionaries:''
@@ -823,7 +823,12 @@
         ^ self
     ].
 
+    (acceptIfUnchanged not
+    and:[model notNil
+    and:[model value = self editValue]]) ifTrue:[^ self].
+
     super accept.
+
     converter notNil ifTrue:[
         val := self editValue.
         string := converter printStringFor:val.
@@ -838,6 +843,23 @@
 
 !EditField methodsFor:'accessing-behavior'!
 
+acceptIfUnchanged
+    "return the acceptIfUnchanged flag setting.
+     if set (the default), an accept notification is sent on accept,
+     even if the fields value is the same. If cleared,
+     the notification is suppressed, if the fields contents is the same."
+
+    ^ acceptIfUnchanged
+!
+
+acceptIfUnchanged:aBoolean
+    "if set (the default), an accept notification is sent on accept,
+     even if the fields value is the same. If cleared,
+     the notification is suppressed, if the fields contents is the same."
+
+    acceptIfUnchanged := aBoolean
+!
+
 acceptOnLeave:aBoolean
     "set/clear the acceptOnLeave flag. The default is false.
      If true, leaving the box (via return, cursor etc.) accepts my 
@@ -1805,6 +1827,7 @@
     acceptOnLeave := acceptOnReturn := acceptOnTab := true.
     cursorShown := true.
     entryCompletionCharacter := #Tab.
+    acceptIfUnchanged := false.
 
     leaveKeys isNil ifTrue:[
         leaveKeys := self class defaultLeaveKeys.
@@ -2073,5 +2096,5 @@
 !EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.146 1999-11-13 13:17:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.147 2000-01-26 14:36:34 ca Exp $'
 ! !