author | Claus Gittinger <cg@exept.de> |
Thu, 07 Mar 1996 13:36:54 +0100 | |
changeset 136 | e1a32c55876a |
parent 113 | 984d84d796c8 |
child 152 | afffa460256a |
permissions | -rw-r--r-- |
12 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 | 3 |
All Rights Reserved |
12 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
136 | 13 |
EditField subclass:#FilenameEditField |
14 |
instanceVariableNames:'directoriesOnly filesOnly directory' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Text' |
|
12 | 18 |
! |
19 |
||
20 |
!FilenameEditField class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 | 25 |
All Rights Reserved |
12 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
24 | 38 |
like a normal editField, but does filename-completion on the last word of |
39 |
the contents, when TAB is pressed. |
|
43 | 40 |
Filename completion ignores regular files if directoriesOnly is true, |
41 |
and ignores directories, if filesOnly is true. Both default to false. |
|
12 | 42 |
" |
43 |
! ! |
|
44 |
||
136 | 45 |
!FilenameEditField methodsFor:'accessing'! |
46 |
||
47 |
directoriesOnly |
|
48 |
"set to expand names for directories only" |
|
49 |
||
50 |
directoriesOnly := true. |
|
51 |
! |
|
52 |
||
53 |
directory |
|
54 |
^ directory |
|
55 |
||
56 |
"Modified: 7.9.1995 / 10:12:40 / claus" |
|
57 |
! |
|
58 |
||
59 |
directory:aFilename |
|
60 |
directory := aFilename asFilename |
|
61 |
||
62 |
"Modified: 7.9.1995 / 10:12:55 / claus" |
|
63 |
! |
|
64 |
||
65 |
filesOnly |
|
66 |
"set to expand names for files only" |
|
67 |
||
68 |
filesOnly := true. |
|
69 |
! |
|
70 |
||
71 |
initialText:aString selected:aBoolean |
|
72 |
"move the cursor to the end - thats the most interesting part of |
|
73 |
a filename |
|
74 |
" |
|
75 |
||
76 |
super initialText:aString selected:aBoolean. |
|
77 |
self cursorToEndOfLine. |
|
78 |
! |
|
79 |
||
80 |
showsDirectoriesOnly |
|
81 |
"return if expanding names for directories only" |
|
82 |
||
83 |
^ directoriesOnly |
|
84 |
||
85 |
"Modified: 6.9.1995 / 20:35:30 / claus" |
|
86 |
! |
|
87 |
||
88 |
showsFilesOnly |
|
89 |
"return if expanding names for files only" |
|
90 |
||
91 |
^ filesOnly |
|
92 |
||
93 |
"Modified: 6.9.1995 / 20:34:57 / claus" |
|
94 |
! ! |
|
95 |
||
96 |
!FilenameEditField methodsFor:'event handling'! |
|
97 |
||
98 |
keyPress:key x:x y:y |
|
99 |
"handle tab for filename completion. |
|
100 |
Bug: it completes the last word; it should complete the |
|
101 |
word before the cursor." |
|
102 |
||
103 |
<resource: #keyboard ( #Tab #FilenameCompletion ) > |
|
104 |
||
105 |
|s| |
|
106 |
||
107 |
enabled ifTrue:[ |
|
108 |
((key == #Tab) |
|
109 |
or:[key == #FilenameCompletion]) ifTrue:[ |
|
110 |
s := self contents. |
|
111 |
s isNil ifTrue:[ |
|
112 |
s := '' |
|
113 |
] ifFalse:[ |
|
114 |
s := s asString |
|
115 |
]. |
|
116 |
entryCompletionBlock value:s. |
|
117 |
^ self |
|
118 |
] |
|
119 |
]. |
|
120 |
^ super keyPress:key x:x y:y. |
|
121 |
||
122 |
"Modified: 7.3.1996 / 13:16:49 / cg" |
|
123 |
! ! |
|
124 |
||
72 | 125 |
!FilenameEditField methodsFor:'initialization'! |
126 |
||
127 |
initialize |
|
128 |
super initialize. |
|
129 |
directoriesOnly := filesOnly := false. |
|
130 |
directory := '.' asFilename. |
|
131 |
||
78 | 132 |
entryCompletionBlock := [:contents | |
133 |
|newString| |
|
134 |
||
135 |
newString := Filename |
|
136 |
filenameCompletionFor:contents |
|
137 |
directory:directory |
|
138 |
directoriesOnly:directoriesOnly |
|
139 |
filesOnly:filesOnly |
|
140 |
ifMultiple:[:dir | |
|
141 |
self changed:#directory with:dir. |
|
142 |
self flash. |
|
143 |
]. |
|
144 |
self contents:newString. |
|
145 |
self cursorToEndOfLine. |
|
72 | 146 |
]. |
147 |
||
148 |
"Modified: 7.9.1995 / 10:20:46 / claus" |
|
43 | 149 |
! |
150 |
||
34 | 151 |
realize |
113
984d84d796c8
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
152 |
"move the cursor to the end - thats the most interesting part of |
34 | 153 |
a filename |
154 |
" |
|
155 |
super realize. |
|
156 |
self cursorToEndOfLine. |
|
157 |
! ! |
|
158 |
||
136 | 159 |
!FilenameEditField class methodsFor:'documentation'! |
43 | 160 |
|
136 | 161 |
version |
162 |
^ '$Header: /cvs/stx/stx/libwidg2/FilenameEditField.st,v 1.19 1996-03-07 12:36:54 cg Exp $' |
|
34 | 163 |
! ! |