empty strings are not nil
authorca
Wed, 10 Jan 1996 15:48:41 +0100
changeset 279 b9fa9180aca4
parent 278 7a01cd530452
child 280 f7d45bfb6d13
empty strings are not nil
EditField.st
--- a/EditField.st	Wed Jan 10 15:48:01 1996 +0100
+++ b/EditField.st	Wed Jan 10 15:48:41 1996 +0100
@@ -758,8 +758,8 @@
     |string|
 
     string := self contents.
+    string isNil ifTrue:[string := ''].
     converter isNil ifTrue:[^ string].
-    string isNil ifTrue:[string := ''].
     ^ converter readValueFrom:string 
 !
 
@@ -1002,52 +1002,53 @@
     |leave xCol newOffset oldWidth newWidth s|
 
     enabled ifFalse:[
-	^ self
+        ^ self
     ].
 
     (key == #DeleteLine) ifTrue:[
-	Smalltalk at:#CopyBuffer put:(self contents).
-	self contents:''. ^ self
+        Smalltalk at:#CopyBuffer put:(self contents).
+        self contents:''. ^ self
     ].
 
     (key == #Tab) ifTrue:[
-	tabAction notNil ifTrue:[tabAction value. ^ self].
-	entryCompletionBlock notNil ifTrue:[
-	    s := self contents.
-	    s isNil ifTrue:[
-		s := ''
-	    ] ifFalse:[
-		s := s asString
-	    ].
-	    entryCompletionBlock value:s. ^ self
-	]
+        tabAction notNil ifTrue:[tabAction value. ^ self].
+        entryCompletionBlock notNil ifTrue:[
+            s := self contents.
+            s isNil ifTrue:[
+                s := ''
+            ] ifFalse:[
+                s := s asString
+            ].
+            entryCompletionBlock value:s. ^ self
+        ]
     ].
     (key == #Return) ifTrue:[
-	crAction notNil ifTrue:[crAction value. ^ self].
+        crAction notNil ifTrue:[crAction value. ^ self].
     ].
     leave := leaveKeys includes:key.
     leave ifTrue:[
-	leaveAction notNil ifTrue:[
-	    leaveAction value:key
-	].
 
-	((key == #Return and:[acceptOnReturn])
-	or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
-	    self accept.
-	].
+        ((key == #Return and:[acceptOnReturn])
+        or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
+            self accept.
+        ].
+
+        leaveAction notNil ifTrue:[
+            ^ leaveAction value:key
+        ].
 
-	x >= 0 ifTrue:[
-	    "
-	     let superview know about the leave ...
-	     This is a temporary kludge for the tableWidget -
-	     it is no clean coding style. Should make the tableWidget
-	     a proper model and handle it via the changed mechanism ....
-	    "
-	    (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
-		superView keyPress:key x:x y:y.
-	    ].
-	].
-	^ self
+        x >= 0 ifTrue:[
+            "
+             let superview know about the leave ...
+             This is a temporary kludge for the tableWidget -
+             it is no clean coding style. Should make the tableWidget
+             a proper model and handle it via the changed mechanism ....
+            "
+            (superView notNil and:[superView canHandle:key from:self]) ifTrue:[
+                superView keyPress:key x:x y:y.
+            ].
+        ].
+        ^ self
     ].
 
     "
@@ -1068,7 +1069,7 @@
      for end-of-text, also move to end-of-line
     "
     key == #EndOfText ifTrue:[
-	super keyPress:#EndOfLine x:x y:y.
+        super keyPress:#EndOfLine x:x y:y.
     ].
     newWidth := self widthOfContents.
 
@@ -1077,11 +1078,11 @@
     "
     xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
     (xCol > (width * (5/6))) ifTrue:[
-	self changed:#preferredExtent
+        self changed:#preferredExtent
     ] ifFalse:[
-	newWidth < (width * (1/6)) ifTrue:[
-	    self changed:#preferredExtent
-	]
+        newWidth < (width * (1/6)) ifTrue:[
+            self changed:#preferredExtent
+        ]
     ].
 
     "
@@ -1090,16 +1091,16 @@
     "
     xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
     (xCol > (width * (5/6))) ifTrue:[
-	newOffset := leftOffset + (width // 2).
+        newOffset := leftOffset + (width // 2).
     ] ifFalse:[
-	(xCol < (width * (1/6))) ifTrue:[
-	    newOffset := 0 max: leftOffset - (width // 2).
-	] ifFalse:[
-	    newOffset := leftOffset
-	]
+        (xCol < (width * (1/6))) ifTrue:[
+            newOffset := 0 max: leftOffset - (width // 2).
+        ] ifFalse:[
+            newOffset := leftOffset
+        ]
     ].
     newOffset ~~ leftOffset ifTrue:[
-	self scrollHorizontalTo:newOffset.
+        self scrollHorizontalTo:newOffset.
 "/        leftOffset := newOffset.
 "/        self clear.
 "/        self redraw
@@ -1317,5 +1318,5 @@
 !EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.36 1995-12-16 15:50:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.37 1996-01-10 14:48:41 ca Exp $'
 ! !