FileSelectionBox.st
changeset 4355 3d88433d2307
parent 3893 de517957b693
child 4629 57dddf95ae31
--- a/FileSelectionBox.st	Mon Jan 23 18:00:31 2012 +0100
+++ b/FileSelectionBox.st	Mon Jan 23 18:24:59 2012 +0100
@@ -462,23 +462,27 @@
     |commonName index s|
 
     something == #directory ifTrue:[
-	"
-	 sent by fileNameEnterField, if a filename
-	 completion was not possible due to multiple
-	 matches.
-	"
-	selectionList directory:argument.
-	s := enterField contents.
-	s notNil ifTrue:[
-	    commonName := s asFilename baseName.
-	    commonName size > 0 ifTrue:[
-		index := selectionList list findFirst:[:entry | entry startsWith:commonName].
-		index ~~ 0 ifTrue:[
-		    selectionList makeLineVisible:index
-		]
-	    ]
-	]
-    ]
+        "
+         sent by fileNameEnterField, if a filename
+         completion was not possible due to multiple
+         matches.
+        "
+        selectionList directory:argument.
+        s := enterField contents.
+        s notNil ifTrue:[
+            commonName := s asFilename baseName.
+            commonName size > 0 ifTrue:[
+                index := selectionList list findFirst:[:entry | entry startsWith:commonName].
+                index ~~ 0 ifTrue:[
+                    selectionList makeLineVisible:index
+                ]
+            ]
+        ]
+    ].
+
+    super update:something with:argument from:changedObject
+
+    "Modified: / 23-01-2012 / 17:35:54 / cg"
 ! !
 
 !FileSelectionBox methodsFor:'initialization'!
@@ -506,7 +510,7 @@
     label := resources string:'File dialog'.
 
     labelField extent:(0.7 @ labelField height).
-    labelField label:(resources string:'select a file:').
+    labelField label:(resources string:'Select a file:').
     labelField adjust:#left.
 
     patternField := EditField in:self.
@@ -516,7 +520,7 @@
         corner := [(width - ViewSpacing - (patternField borderWidth * 2)) @ (labelField origin y+patternField height"IncludingBorder")].
     ].
     patternField origin:(0.7 @ labelField origin y) corner:corner.
-    patternField rightInset:ViewSpacing.
+    patternField rightInset:0.
     patternField initialText:'*'.
     patternField leaveAction:[:reason | self patternChanged]. 
     patternField crAction:[self patternChanged].
@@ -524,7 +528,12 @@
 "/ no, since its invisible
 "/    self makeTabable:patternField before:enterField.
 
+    enterField 
+        origin:[0.0 @ (ViewSpacing + ViewSpacing + (labelField preferredHeight max:patternField preferredHeight) "height")].
     enterField addDependent:self.
+    "/ enterField immediateAccept:true.
+    enterField acceptAction:[:newFile | self enterFieldChanged ].
+    enterField crAction:[:newFile | self enterFieldChanged. self okPressed ].
 
     selectionList menuHolder:self; menuMessage:#fileListMenu; menuPerformer:self.
     selectionList ignoreCaseInPattern:true.
@@ -534,7 +543,7 @@
      FileSelectionBox new show
     "
 
-    "Modified: 18.10.1997 / 02:47:49 / cg"
+    "Modified: / 23-01-2012 / 18:18:47 / cg"
 !
 
 postRealize
@@ -698,6 +707,23 @@
     "Modified: 19.10.1997 / 00:17:37 / cg"
 !
 
+enterFieldChanged
+    |fn dir|
+
+    fn := enterField contents.
+    (dir := fn asFilename) exists ifFalse:[
+        dir := dir directory.
+    ].
+    dir exists ifTrue:[
+        dir isDirectory ifFalse:[
+            dir := dir directory
+        ].
+        selectionList changeDirectoryTo:dir pathName
+    ].
+
+    "Created: / 23-01-2012 / 18:10:32 / cg"
+!
+
 okPressed
     "called for both on ok-press and on return-key"
 
@@ -756,5 +782,5 @@
 !FileSelectionBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.69 2009-05-20 07:18:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionBox.st,v 1.70 2012-01-23 17:24:59 cg Exp $'
 ! !