author | Claus Gittinger <cg@exept.de> |
Mon, 15 Feb 1999 13:39:53 +0100 | |
changeset 1739 | 3cb6e85d42c0 |
parent 1733 | c5139b7402f0 |
child 1751 | f29c3312beaf |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
||
13 |
EditTextView subclass:#EditField |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
14 |
instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter |
209
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
15 |
leaveKeys immediateAccept acceptOnLeave acceptOnReturn |
979 | 16 |
lengthLimit entryCompletionBlock entryCompletionCharacter |
17 |
passwordCharacter cursorMovementWhenUpdating enableChannel |
|
18 |
autoScrollHorizontally acceptOnTab acceptOnLostFocus' |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
19 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
20 |
DefaultSelectionForegroundColor DefaultSelectionBackgroundColor' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
21 |
poolDictionaries:'' |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
22 |
category:'Views-Text' |
0 | 23 |
! |
24 |
||
892 | 25 |
!EditField class methodsFor:'documentation'! |
19 | 26 |
|
38 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 30 |
All Rights Reserved |
38 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
19 | 41 |
documentation |
42 |
" |
|
38 | 43 |
an editable text-field. Realized by using an EditTextView, |
44 |
and forcing its size to 1 line - disabling cursor movement |
|
45 |
in the vertical direction. |
|
121 | 46 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
47 |
Basically, an editField is an editor for a single line text, |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
48 |
and provides the usual access protocol as defined in its superClasses |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
49 |
(especially: #contents / #contents:). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
50 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
51 |
The above underlying internal mechanism can be used for fields which |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
52 |
are passive; i.e. into which text can be entered and the value (string) |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
53 |
is extracted actively by someone else. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
54 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
55 |
accepting: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
56 |
The opposite way to use editFields is to connect them to a model |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
57 |
and let the field notify changes to it. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
58 |
This notification is called ``accepting''. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
59 |
Unless accepted, the models value is not updated from the editFields contents |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
60 |
this default is the normal operation and way things should work, since most |
842
a27a1c6ddde0
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
832
diff
changeset
|
61 |
uses of editFields are not interested in every individual change |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
62 |
(i.e. getting each keyStroke when a long number is entered). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
63 |
The default behavior is to ``accept'' when either return or a cursorUp/Down |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
64 |
key is pressed in a field. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
65 |
However, the field can setup to accept/not accept on leave, on return |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
66 |
or on each individual key input. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
67 |
See the methods #acceptOnLeave: / #acceptOnReturn: / #immediateAccept. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
68 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
69 |
In addition, the set of keys which are considered ``leaveKeys'' can be |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
70 |
specified by #leaveKeys: (in case you need keys other than Return, CursorUp/Down). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
71 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
72 |
models value vs. field contents: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
73 |
Although the field internally keeps its contents as some string object, |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
74 |
the application may prefer to think of numbers, floats, yes/no values etc. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
75 |
To support this, a converter may defined, which is responsible for conversion of |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
76 |
strings to/from the models domain value. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
77 |
If present (i.e. nonNil), the converter is asked to convert a string to the models |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
78 |
domain with #readValueFrom:aString and vice versa, a value to a string by #printStringFor:. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
79 |
The PrintConverter class already provides a number of standard conversions, see the examples. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
80 |
To access a converted value directly (i.e. not via the model), use #editValue. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
81 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
82 |
grouping: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
83 |
Individual fields do not know about being included in a group. This must be arranged on the |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
84 |
outside, by placing multiple fields into an EnterFieldGroup. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
85 |
This groupObject keeps a reference to one active field, and forwards input from any other |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
86 |
field to the active one. Also have a look at the examples for this. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
87 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
88 |
input completion: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
89 |
To support input completion (i.e. filename completion, classname completion etc.), |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
90 |
a completionBlock can be defined which (if non-nil) is evaluated when the completion-key |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
91 |
is pressed and its value is taken as the new field-contents. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
92 |
The physical completion-key is the Tab key (this one cannot be defined by |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
93 |
the keyboardTranslation mechanism, since that would disable the Tab-key on regular text views. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
94 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
95 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
96 |
|
586 | 97 |
[Instance variables:] |
121 | 98 |
|
99 |
leaveAction <Block | nil> if non-nil, this is evaluated with |
|
586 | 100 |
the key (#Return, #CursorUp etc.) when |
101 |
the field is left via keyboard keys. |
|
102 |
(fieldGroups use this to decide which |
|
103 |
field has to be enabled next) |
|
121 | 104 |
|
105 |
enabled <Boolean> if false, input is ignored. |
|
106 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
107 |
clickAction <Block | nil> action performed if the field is |
586 | 108 |
clicked upon. |
109 |
(this is used by the group to |
|
110 |
set the active field to the clicked upon field) |
|
121 | 111 |
|
112 |
crAction <Block | nil> if non-nil, keyboard input of a cr are not |
|
586 | 113 |
handled specially, instead this block is evaluated |
114 |
(however, this block can perform additional checks and send |
|
115 |
a #accept then) |
|
121 | 116 |
|
117 |
tabAction <Block | nil> if non-nil, keyboard input of a tab character |
|
586 | 118 |
is not entered into the text, instead this block |
119 |
is evaluated. Also, no input completion is performed if |
|
120 |
tabAction is nonNil. |
|
121 | 121 |
|
122 |
converter <PrintConverter | nil> if non-nil, this is supposed to convert between |
|
586 | 123 |
the object and its printed representation and vice versa. |
124 |
Defaults to nil i.e. assume that strings are edited. |
|
121 | 125 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
126 |
leaveKeys <Collection> keys which are interpreted as 'leaving the field' |
122 | 127 |
|
125 | 128 |
immediateAccept <Boolean> if true, every change of the text is immediately |
586 | 129 |
forwarded to the model/acceptBlock. If false, |
130 |
the changed value is only stored in the model |
|
131 |
if the field is left or accepted. |
|
132 |
Default is false. |
|
122 | 133 |
|
134 |
acceptOnLeave <Boolean> if true, leaving the field (via cursor keys) |
|
586 | 135 |
automatically accepts the value into the model. |
136 |
Default is true. |
|
122 | 137 |
|
138 |
acceptOnReturn <Boolean> if true, leaving the field via return |
|
586 | 139 |
automatically accepts the value into the model. |
140 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
141 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
142 |
acceptOnTab <Boolean> if true, the Tab key accepts and leaves the field. |
586 | 143 |
If false, Tabs are entered into the contents field like |
144 |
ordinary non-control keys. |
|
145 |
AcceptOnTab is ignored if the entryCompletion block is nonNil. |
|
146 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
147 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
148 |
lengthLimit <Number> the max. number of allowed characters |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
149 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
150 |
entryCompletionBlock <BlockOrNil> if non-nil, this is evaluated to complete the entry |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
151 |
when <entryCompletionCharacter> is pressed. |
586 | 152 |
Entry completion is used with Filenamefields or in the |
153 |
browser for classname/selector completion. |
|
154 |
Setting a nonNil entryCompletion disables acceptOnTab. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
155 |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
156 |
entryCompletionCharacter <CharacterOrNil> if non-nil AND entryCompletionBlock is nonNil, that one |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
157 |
is evaluated for completion. Typically used to complete |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
158 |
a fileName (also, classNames in the browser) |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
159 |
Default is #Tab. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
160 |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
161 |
passwordCharacter <CharacterOrNil> if non-nil, typed input is replaced by this character |
586 | 162 |
for display. Used for secret-input fields (such as password entry). |
163 |
Default is nil. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
164 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
165 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
166 |
cursorMovementWhenUpdating <Symbol> defines where the cursor is to be positioned if the |
586 | 167 |
model changes its value by some outside activity |
168 |
(i.e. not by user input into the field). |
|
169 |
Can be one of: |
|
170 |
#keep / nil -> stay where it was |
|
171 |
#endOfLine -> position cursor after the string |
|
172 |
#beginOfLine -> position cursor to the beginning |
|
173 |
The default is nil (i.e. stay where it was before). |
|
174 |
||
175 |
[author:] |
|
176 |
Claus Gittinger |
|
177 |
||
178 |
[see also:] |
|
179 |
DialogBox |
|
594 | 180 |
EnterFieldGroup |
181 |
EnterBox EnterBox2 |
|
182 |
FilenameEditField EditTextView |
|
19 | 183 |
" |
120 | 184 |
! |
185 |
||
186 |
examples |
|
187 |
" |
|
122 | 188 |
see more examples in EnterFieldGroup>>examples. |
189 |
||
190 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
191 |
Step-by-step introduction: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
192 |
|
120 | 193 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
194 |
basic field in some view: |
594 | 195 |
[exBegin] |
333 | 196 |
|top field| |
120 | 197 |
|
333 | 198 |
top := StandardSystemView new. |
199 |
top extent:200@100. |
|
120 | 200 |
|
333 | 201 |
field := EditField origin:0.0@0.0 in:top. |
202 |
field width:1.0. 'let its height as-is'. |
|
120 | 203 |
|
333 | 204 |
top open |
594 | 205 |
[exEnd] |
120 | 206 |
|
122 | 207 |
|
125 | 208 |
forward input in topView to the field: |
209 |
(currently, the field does not know this - therefore, |
|
210 |
its been told here ... this may change) |
|
594 | 211 |
[exBegin] |
333 | 212 |
|top field| |
122 | 213 |
|
333 | 214 |
top := StandardSystemView new. |
215 |
top extent:200@100. |
|
122 | 216 |
|
333 | 217 |
field := EditField origin:0.0@0.0 in:top. |
218 |
field width:1.0. 'let its height as-is'. |
|
122 | 219 |
|
333 | 220 |
top delegate:(KeyboardForwarder toView:field). |
221 |
field hasKeyboardFocus:true. |
|
222 |
top open |
|
594 | 223 |
[exEnd] |
122 | 224 |
|
225 |
||
125 | 226 |
to make it look better: set some inset: |
594 | 227 |
[exBegin] |
333 | 228 |
|top field spacing| |
120 | 229 |
|
333 | 230 |
top := StandardSystemView new. |
231 |
top extent:200@100. |
|
120 | 232 |
|
333 | 233 |
spacing := View viewSpacing. |
234 |
field := EditField origin:(0.0 @ spacing) in:top. |
|
235 |
field width:1.0. 'let its height as-is'. |
|
236 |
field leftInset:spacing; rightInset:spacing. |
|
120 | 237 |
|
333 | 238 |
top open |
594 | 239 |
[exEnd] |
120 | 240 |
|
122 | 241 |
|
120 | 242 |
give it an initial contents: |
594 | 243 |
[exBegin] |
333 | 244 |
|top field| |
120 | 245 |
|
333 | 246 |
top := StandardSystemView new. |
247 |
top extent:200@100. |
|
120 | 248 |
|
594 | 249 |
field := EditField origin:(0.0 @ 0.0) in:top. |
333 | 250 |
field width:1.0. |
120 | 251 |
|
333 | 252 |
field editValue:'hello world'. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
253 |
|
333 | 254 |
top open |
594 | 255 |
[exEnd] |
120 | 256 |
|
122 | 257 |
|
125 | 258 |
have it preselected: |
594 | 259 |
[exBegin] |
333 | 260 |
|top field| |
120 | 261 |
|
333 | 262 |
top := StandardSystemView new. |
263 |
top extent:200@100. |
|
120 | 264 |
|
333 | 265 |
field := EditField origin:(0.0 @ 0.0) in:top. |
266 |
field width:1.0. |
|
267 |
field editValue:'hello world' selected:true. |
|
120 | 268 |
|
333 | 269 |
top open |
594 | 270 |
[exEnd] |
120 | 271 |
|
122 | 272 |
|
120 | 273 |
have part of it preselected: |
594 | 274 |
[exBegin] |
333 | 275 |
|top field| |
120 | 276 |
|
333 | 277 |
top := StandardSystemView new. |
278 |
top extent:200@100. |
|
120 | 279 |
|
333 | 280 |
field := EditField origin:(0.0 @ 0.0) in:top. |
281 |
field width:1.0. |
|
120 | 282 |
|
333 | 283 |
field editValue:'hello world'. |
284 |
field selectFromCharacterPosition:1 to:5. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
285 |
|
333 | 286 |
top open |
594 | 287 |
[exEnd] |
120 | 288 |
|
122 | 289 |
|
125 | 290 |
set a size limit: |
594 | 291 |
[exBegin] |
333 | 292 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
293 |
|
333 | 294 |
top := StandardSystemView new. |
295 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
296 |
|
333 | 297 |
field := EditField origin:(0.0 @ 0.0) in:top. |
298 |
field width:1.0. |
|
299 |
field editValue:'hello'. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
300 |
|
333 | 301 |
field maxChars:8. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
302 |
|
333 | 303 |
top open |
594 | 304 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
305 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
306 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
307 |
set a size limit, initial width and stop it from scrolling |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
308 |
notice: you may prefer a constant-pitch font (such as courier): |
594 | 309 |
[exBegin] |
333 | 310 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
311 |
|
333 | 312 |
top := StandardSystemView new. |
313 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
314 |
|
333 | 315 |
field := EditField origin:(0.0 @ 0.0) in:top. |
316 |
field innerWidth:(field font widthOf:'00000000'). |
|
317 |
field editValue:'12345678'. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
318 |
|
333 | 319 |
field maxChars:8. |
320 |
field autoScroll:false. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
321 |
|
333 | 322 |
top open |
594 | 323 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
324 |
|
125 | 325 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
326 |
enable / disable: |
594 | 327 |
[exBegin] |
333 | 328 |
|top panel check field ena| |
329 |
||
330 |
top := StandardSystemView new. |
|
331 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
332 |
|
333 | 333 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
334 |
panel borderWidth:0. |
|
335 |
panel horizontalLayout:#left. |
|
336 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
337 |
|
333 | 338 |
check := CheckBox label:'enable' in:panel. |
339 |
check turnOn. |
|
340 |
check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]]. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
341 |
|
333 | 342 |
panel add:(View new height:30; borderWidth:0). |
125 | 343 |
|
333 | 344 |
field := EditField in:panel. |
345 |
field width:1.0. |
|
346 |
field editValue:'hello'. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
347 |
|
333 | 348 |
top open |
594 | 349 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
350 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
351 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
352 |
enable / disable using a channel: |
594 | 353 |
[exBegin] |
333 | 354 |
|top panel check field ena| |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
355 |
|
333 | 356 |
top := StandardSystemView new. |
357 |
top extent:200@100. |
|
125 | 358 |
|
333 | 359 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
360 |
panel borderWidth:0. |
|
361 |
panel horizontalLayout:#left. |
|
362 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
363 |
|
333 | 364 |
ena := true asValue. |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
365 |
|
333 | 366 |
check := CheckBox label:'enable' in:panel. |
367 |
check model:ena. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
368 |
|
333 | 369 |
panel add:(View new height:30; borderWidth:0). |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
370 |
|
333 | 371 |
field := EditField in:panel. |
372 |
field enableChannel:ena. |
|
373 |
field width:1.0. |
|
374 |
field editValue:'hello'. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
375 |
|
333 | 376 |
top open |
594 | 377 |
[exEnd] |
125 | 378 |
|
379 |
||
121 | 380 |
use a converter: |
125 | 381 |
- numbers (default to 0): |
594 | 382 |
[exBegin] |
383 |
|top field spacing| |
|
121 | 384 |
|
333 | 385 |
top := StandardSystemView new. |
386 |
top extent:200@100. |
|
121 | 387 |
|
594 | 388 |
spacing := View viewSpacing. |
389 |
||
390 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 391 |
field width:1.0. |
594 | 392 |
field horizontalInset:spacing. |
121 | 393 |
|
333 | 394 |
field converter:(PrintConverter new initForNumber). |
395 |
field editValue:1234. |
|
655 | 396 |
field acceptAction:[:value | Transcript showCR:value]. |
333 | 397 |
field crAction:[field accept. top destroy]. |
398 |
top open. |
|
594 | 399 |
[exEnd] |
121 | 400 |
|
401 |
- dates: |
|
594 | 402 |
[exBegin] |
403 |
|top field spacing| |
|
121 | 404 |
|
333 | 405 |
top := StandardSystemView new. |
406 |
top extent:200@100. |
|
121 | 407 |
|
594 | 408 |
spacing := View viewSpacing. |
409 |
||
410 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 411 |
field width:1.0. |
594 | 412 |
field horizontalInset:spacing. |
121 | 413 |
|
333 | 414 |
field converter:(PrintConverter new initForDate). |
415 |
field editValue:Date today. |
|
655 | 416 |
field acceptAction:[:value | Transcript showCR:value class name , ' ' , value printString]. |
333 | 417 |
field crAction:[field accept. top destroy]. |
418 |
top open. |
|
594 | 419 |
[exEnd] |
121 | 420 |
|
122 | 421 |
|
125 | 422 |
setting immediateAccept, makes the field update with every key: |
423 |
||
424 |
- immediate accept numbers, defaulting to nil: |
|
594 | 425 |
[exBegin] |
426 |
|top field spacing| |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
427 |
|
333 | 428 |
top := StandardSystemView new. |
429 |
top extent:200@100. |
|
121 | 430 |
|
594 | 431 |
spacing := View viewSpacing. |
432 |
||
433 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 434 |
field width:1.0. |
594 | 435 |
field horizontalInset:spacing. |
121 | 436 |
|
333 | 437 |
field converter:(PrintConverter new initForNumberOrNil). |
438 |
field immediateAccept:true. |
|
439 |
field editValue:1234. |
|
655 | 440 |
field acceptAction:[:value | Transcript showCR:value]. |
333 | 441 |
field crAction:[field accept. top destroy]. |
442 |
top open. |
|
594 | 443 |
[exEnd] |
121 | 444 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
445 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
446 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
447 |
grouping multiple fields, and forward keyPres from the outer view to the active field |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
448 |
(i.e. actually: to the group): |
594 | 449 |
[exBegin] |
333 | 450 |
|top field1 field2 field3 group| |
121 | 451 |
|
122 | 452 |
|
333 | 453 |
top := StandardSystemView new. |
454 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
455 |
|
333 | 456 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
457 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
458 |
|
333 | 459 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
460 |
field2 width:0.5. |
|
461 |
field2 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
462 |
|
333 | 463 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
464 |
field3 width:0.5. |
|
465 |
field3 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
466 |
|
333 | 467 |
group := EnterFieldGroup new. |
468 |
group add:field1; add:field2; add:field3. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
469 |
|
333 | 470 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
471 |
|
333 | 472 |
top open. |
594 | 473 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
474 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
475 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
476 |
in addition: tell the group to close when the last field is left: |
594 | 477 |
[exBegin] |
333 | 478 |
|top field1 field2 field3 group| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
479 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
480 |
|
333 | 481 |
top := StandardSystemView new. |
482 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
483 |
|
333 | 484 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
485 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
486 |
|
333 | 487 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
488 |
field2 width:0.5. |
|
489 |
field2 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
490 |
|
333 | 491 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
492 |
field3 width:0.5. |
|
493 |
field3 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
494 |
|
333 | 495 |
group := EnterFieldGroup new. |
496 |
group add:field1; add:field2; add:field3. |
|
497 |
group leaveAction:[top destroy]. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
498 |
|
333 | 499 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
500 |
|
333 | 501 |
top open. |
594 | 502 |
[exEnd] |
127 | 503 |
|
504 |
||
120 | 505 |
use a model: |
506 |
(see changing model value in inspector when return is pressed in the field) |
|
594 | 507 |
[exBegin] |
333 | 508 |
|top field model| |
120 | 509 |
|
333 | 510 |
model := 'hello world' asValue. |
120 | 511 |
|
333 | 512 |
top := StandardSystemView new. |
513 |
top extent:200@100. |
|
120 | 514 |
|
333 | 515 |
field := EditField origin:(0.0 @ 0.0) in:top. |
516 |
field width:1.0. |
|
517 |
field model:model. |
|
518 |
field acceptOnReturn:true. |
|
120 | 519 |
|
333 | 520 |
top open. |
521 |
model inspect. |
|
594 | 522 |
[exEnd] |
121 | 523 |
|
122 | 524 |
|
892 | 525 |
like above, but also accept the value, when the focus is changed |
894 | 526 |
(i.e. out of the input field): |
892 | 527 |
(see changing model value in inspector) |
528 |
[exBegin] |
|
529 |
|top field model| |
|
530 |
||
531 |
model := 'hello world' asValue. |
|
532 |
||
533 |
top := StandardSystemView new. |
|
534 |
top extent:200@100. |
|
535 |
||
536 |
field := EditField origin:(0.0 @ 0.0) in:top. |
|
537 |
field width:1.0. |
|
538 |
field model:model. |
|
539 |
field acceptOnLostFocus:true. |
|
540 |
||
541 |
top open. |
|
894 | 542 |
InspectorView openOn:model monitor:'value'. |
892 | 543 |
[exEnd] |
544 |
||
545 |
||
127 | 546 |
two views on the same model (each accepts on return): |
594 | 547 |
[exBegin] |
333 | 548 |
|top1 top2 field1 field2 model| |
121 | 549 |
|
333 | 550 |
model := 'hello world' asValue. |
121 | 551 |
|
333 | 552 |
top1 := StandardSystemView new. |
553 |
top1 extent:200@100. |
|
554 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
555 |
field1 width:1.0. |
|
556 |
field1 model:model. |
|
557 |
field1 acceptOnReturn:true. |
|
558 |
top1 open. |
|
121 | 559 |
|
333 | 560 |
top2 := StandardSystemView new. |
561 |
top2 extent:200@100. |
|
562 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
563 |
field2 width:1.0. |
|
564 |
field2 model:model. |
|
565 |
field2 acceptOnReturn:true. |
|
566 |
top2 open. |
|
594 | 567 |
[exEnd] |
121 | 568 |
|
127 | 569 |
two views on the same model (no accept on return): |
594 | 570 |
[exBegin] |
333 | 571 |
|top1 top2 field1 field2 model| |
127 | 572 |
|
333 | 573 |
model := 'hello world' asValue. |
127 | 574 |
|
333 | 575 |
top1 := StandardSystemView new. |
576 |
top1 extent:200@100. |
|
577 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
578 |
field1 width:1.0. |
|
579 |
field1 model:model; acceptOnReturn:false. |
|
580 |
top1 open. |
|
127 | 581 |
|
333 | 582 |
top2 := StandardSystemView new. |
583 |
top2 extent:200@100. |
|
584 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
585 |
field2 width:1.0. |
|
586 |
field2 model:model; acceptOnReturn:false. |
|
587 |
top2 open. |
|
594 | 588 |
[exEnd] |
127 | 589 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
590 |
with immediate accept (every key updates the model): |
594 | 591 |
[exBegin] |
333 | 592 |
|top1 top2 field1 field2 model| |
125 | 593 |
|
333 | 594 |
model := 'hello world' asValue. |
125 | 595 |
|
333 | 596 |
top1 := StandardSystemView new. |
597 |
top1 extent:200@100. |
|
598 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
599 |
field1 width:1.0. |
|
600 |
field1 model:model; immediateAccept:true. |
|
601 |
top1 open. |
|
125 | 602 |
|
333 | 603 |
top2 := StandardSystemView new. |
604 |
top2 extent:200@100. |
|
605 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
606 |
field2 width:1.0. |
|
607 |
field2 model:model; immediateAccept:true. |
|
608 |
top2 open. |
|
594 | 609 |
[exEnd] |
122 | 610 |
|
121 | 611 |
just an example; a checkBox and an editField on the same model: |
594 | 612 |
[exBegin] |
333 | 613 |
|top1 top2 field1 box model| |
121 | 614 |
|
333 | 615 |
model := false asValue. |
121 | 616 |
|
333 | 617 |
top1 := StandardSystemView new. |
618 |
top1 extent:200@100. |
|
619 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
620 |
field1 width:1.0. |
|
621 |
field1 converter:(PrintConverter new initForYesNo). |
|
622 |
field1 model:model. |
|
623 |
top1 open. |
|
121 | 624 |
|
333 | 625 |
top2 := StandardSystemView new. |
626 |
top2 extent:200@100. |
|
627 |
box := CheckBox on:model. |
|
628 |
box label:'on/off'. |
|
629 |
top2 add:box. |
|
630 |
top2 open. |
|
121 | 631 |
|
333 | 632 |
model inspect. |
594 | 633 |
[exEnd] |
125 | 634 |
|
635 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
636 |
multiple editFields on multiple models (value holders): |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
637 |
(the fields are connected by a group to allow tabbing) |
594 | 638 |
[exBegin] |
639 |
|top panel group field1 field2 field3 box |
|
640 |
v1 v2 v3 spacing| |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
641 |
|
333 | 642 |
v1 := true asValue. |
643 |
v2 := 'some string' asValue. |
|
644 |
v3 := 1.2 asValue. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
645 |
|
333 | 646 |
top := StandardSystemView new. |
647 |
top extent:200@100. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
648 |
|
333 | 649 |
panel := VerticalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
650 |
|
594 | 651 |
spacing := View viewSpacing. |
652 |
||
333 | 653 |
field1 := EditField new. |
654 |
field1 width:1.0. |
|
594 | 655 |
field1 horizontalInset:spacing. |
333 | 656 |
field1 converter:(PrintConverter new initForYesNo). |
657 |
field1 model:v1. |
|
658 |
panel add:field1. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
659 |
|
333 | 660 |
field2 := EditField new. |
661 |
field2 width:1.0. |
|
594 | 662 |
field2 horizontalInset:spacing. |
333 | 663 |
field2 model:v2. |
664 |
panel add:field2. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
665 |
|
333 | 666 |
field3 := EditField new. |
667 |
field3 width:1.0. |
|
594 | 668 |
field3 horizontalInset:spacing. |
333 | 669 |
field3 converter:(PrintConverter new initForNumber). |
670 |
field3 model:v3. |
|
671 |
panel add:field3. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
672 |
|
333 | 673 |
group := EnterFieldGroup new. |
674 |
group add:field1; add:field2; add:field3. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
675 |
|
333 | 676 |
top openModal. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
677 |
|
655 | 678 |
Transcript showCR:v1 value. |
679 |
Transcript showCR:v2 value. |
|
680 |
Transcript showCR:v3 value. |
|
594 | 681 |
[exEnd] |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
682 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
683 |
|
125 | 684 |
connecting fields: |
685 |
update field2 wehenever field1 is changed. |
|
686 |
(normally, the processing below (xChanged) is done in your application |
|
687 |
class, or in a complex model. For the demonstration below, we use |
|
688 |
a Plug to simulate the protocol.) |
|
594 | 689 |
[exBegin] |
333 | 690 |
|application top field1 field2 value1 value2| |
125 | 691 |
|
333 | 692 |
application := Plug new. |
693 |
application respondTo:#value1Changed |
|
694 |
with:[value2 value:(value1 value isNil ifTrue:[nil] |
|
695 |
ifFalse:[value1 value squared])]. |
|
125 | 696 |
|
333 | 697 |
value1 := 1 asValue. |
698 |
value2 := 1 asValue. |
|
125 | 699 |
|
333 | 700 |
top := Dialog new. |
701 |
top extent:200@200. |
|
125 | 702 |
|
333 | 703 |
(top addTextLabel:'some number:') layout:#left. |
704 |
top addVerticalSpace. |
|
125 | 705 |
|
333 | 706 |
(top addInputFieldOn:value1 tabable:false) |
707 |
converter:(PrintConverter new initForNumberOrNil); |
|
708 |
immediateAccept:true. |
|
709 |
top addVerticalSpace. |
|
125 | 710 |
|
333 | 711 |
(top addTextLabel:'squared:') layout:#left. |
712 |
top addVerticalSpace. |
|
713 |
(top addInputFieldOn:value2 tabable:false) |
|
714 |
converter:(PrintConverter new initForNumberOrNil). |
|
125 | 715 |
|
333 | 716 |
value1 onChangeSend:#value1Changed to:application. |
125 | 717 |
|
333 | 718 |
top openModeless. |
594 | 719 |
[exEnd] |
125 | 720 |
|
721 |
||
722 |
two-way connect: |
|
723 |
each field updates the other (notice, that we have to turn off |
|
724 |
onChange: notification, to avoid an endless notification cycle) |
|
594 | 725 |
[exBegin] |
333 | 726 |
|application top field1 field2 value1 value2| |
125 | 727 |
|
333 | 728 |
application := Plug new. |
729 |
application respondTo:#value1Changed |
|
730 |
with:[value2 retractInterestsFor:application. |
|
731 |
value2 value:(value1 value isNil ifTrue:[nil] |
|
732 |
ifFalse:[value1 value squared]). |
|
733 |
value2 onChangeSend:#value2Changed to:application. |
|
734 |
]. |
|
735 |
application respondTo:#value2Changed |
|
736 |
with:[value1 retractInterestsFor:application. |
|
737 |
value1 value:(value2 value isNil ifTrue:[nil] |
|
738 |
ifFalse:[value2 value sqrt]). |
|
739 |
value1 onChangeSend:#value1Changed to:application. |
|
740 |
]. |
|
125 | 741 |
|
333 | 742 |
value1 := 1 asValue. |
743 |
value2 := 1 asValue. |
|
125 | 744 |
|
333 | 745 |
top := Dialog new. |
746 |
top extent:200@200. |
|
125 | 747 |
|
333 | 748 |
(top addTextLabel:'some number:') layout:#left. |
749 |
top addVerticalSpace. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
750 |
|
333 | 751 |
(top addInputFieldOn:value1 tabable:false) |
752 |
converter:(PrintConverter new initForNumberOrNil); |
|
753 |
immediateAccept:true. |
|
754 |
top addVerticalSpace. |
|
125 | 755 |
|
333 | 756 |
(top addTextLabel:'squared:') layout:#left. |
757 |
top addVerticalSpace. |
|
758 |
(top addInputFieldOn:value2 tabable:false) |
|
759 |
converter:(PrintConverter new initForNumberOrNil); |
|
760 |
immediateAccept:true. |
|
125 | 761 |
|
333 | 762 |
value1 onChangeSend:#value1Changed to:application. |
763 |
value2 onChangeSend:#value2Changed to:application. |
|
125 | 764 |
|
333 | 765 |
top openModeless. |
594 | 766 |
[exEnd] |
120 | 767 |
" |
19 | 768 |
! ! |
0 | 769 |
|
892 | 770 |
!EditField class methodsFor:'defaults'! |
0 | 771 |
|
125 | 772 |
defaultLeaveKeys |
128 | 773 |
"return the set of keys which are taken as leave-keys. |
774 |
If the field is in an enterFieldGroup, all leave keys will be |
|
775 |
forwarded to the group and possible step to the next/previous field. |
|
776 |
Also, if acceptOnLeave is true, leave keys will store the current |
|
777 |
value into their model (if any)" |
|
778 |
||
125 | 779 |
^ #(Return CursorUp CursorDown Next Previous Accept) |
780 |
! |
|
781 |
||
192 | 782 |
defaultNumberOfLines |
783 |
"the number of lines in the field" |
|
784 |
||
785 |
^ 1 |
|
786 |
! |
|
787 |
||
59 | 788 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
789 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
790 |
|
1354 | 791 |
<resource: #style (#'editField.foregroundColor' #'editField.backgroundColor' |
792 |
#'editField.selectionForegroundColor' #'editFieldSelectionBackgroundColor' |
|
793 |
#'editField.font')> |
|
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
794 |
|
1354 | 795 |
DefaultForegroundColor := StyleSheet colorAt:'editField.foregroundColor' default:Black. |
796 |
DefaultBackgroundColor := StyleSheet colorAt:'editField.backgroundColor' default:White. |
|
797 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'editField.selectionForegroundColor' default:DefaultBackgroundColor. |
|
798 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'editField.selectionBackgroundColor' default:DefaultForegroundColor. |
|
799 |
DefaultFont := StyleSheet fontAt:'editField.font' default:nil. |
|
59 | 800 |
|
801 |
" |
|
60 | 802 |
self updateStyleCache |
59 | 803 |
" |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
804 |
|
1354 | 805 |
"Modified: 20.10.1997 / 15:02:07 / cg" |
0 | 806 |
! ! |
807 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
808 |
!EditField methodsFor:'accepting'! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
809 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
810 |
accept |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
811 |
"" |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
812 |
|val string| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
813 |
|
1108 | 814 |
acceptEnabled == false ifTrue:[ |
815 |
device beep. |
|
816 |
^ self |
|
817 |
]. |
|
818 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
819 |
super accept. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
820 |
converter notNil ifTrue:[ |
1108 | 821 |
val := self editValue. |
822 |
string := converter printStringFor:val. |
|
823 |
string ~= self contents ifTrue:[ |
|
824 |
self contents:string. |
|
825 |
self flash |
|
826 |
] |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
827 |
]. |
1108 | 828 |
|
829 |
"Modified: 7.3.1997 / 11:06:00 / cg" |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
830 |
! ! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
831 |
|
192 | 832 |
!EditField methodsFor:'accessing-behavior'! |
125 | 833 |
|
192 | 834 |
acceptOnLeave:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
835 |
"set/clear the acceptOnLeave flag. The default is false. |
892 | 836 |
If true, leaving the box (via return, cursor etc.) accepts my |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
837 |
string into the valueHolder (if any). |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
838 |
(actually, the set of keys can be specified with #leaveKeys:)" |
125 | 839 |
|
192 | 840 |
acceptOnLeave := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
841 |
|
892 | 842 |
"Modified: 11.12.1996 / 16:47:25 / cg" |
843 |
! |
|
844 |
||
845 |
acceptOnLostFocus:aBoolean |
|
846 |
"set/clear the acceptOnLostFocus flag. The default is false. |
|
847 |
If true, a lost focus (via mouse-pointer motion etc.) accepts my |
|
848 |
string into the valueHolder (if any)." |
|
849 |
||
850 |
acceptOnLostFocus := aBoolean |
|
851 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
852 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
892 | 853 |
"Created: 11.12.1996 / 16:48:00 / cg" |
192 | 854 |
! |
855 |
||
856 |
acceptOnReturn:aBoolean |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
857 |
"set/clear the acceptOnReturn flag. The default is false. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
858 |
If true, leaving the box via return accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
859 |
string into the valueHolder (if any)." |
192 | 860 |
|
861 |
acceptOnReturn := aBoolean |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
862 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
863 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
125 | 864 |
! |
865 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
866 |
acceptOnTab:aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
867 |
"set/clear the acceptOnTab flag. The default is true. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
868 |
If true, a pressed Tab key accepts and leaves the box. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
869 |
If false, the Tab key is treated like any normal input character |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
870 |
(i.e. inserted into the contents)." |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
871 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
872 |
acceptOnTab := aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
873 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
874 |
"Created: 24.1.1996 / 13:13:37 / cg" |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
875 |
! |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
876 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
877 |
autoScroll:aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
878 |
"turn on/off automatic scrolling upon keyboard entry |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
879 |
to make the cursor visible." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
880 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
881 |
autoScrollHorizontally := aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
882 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
883 |
|
325 | 884 |
clickAction:aBlock |
885 |
"define an action to be evaluated when being clicked upon" |
|
886 |
||
887 |
clickAction := aBlock |
|
888 |
! |
|
889 |
||
192 | 890 |
crAction:aBlock |
891 |
"define an action to be evaluated when the return key is pressed." |
|
892 |
||
893 |
crAction := aBlock |
|
894 |
! |
|
125 | 895 |
|
192 | 896 |
cursorMovementWhenUpdating:aSymbol |
897 |
"define what should be done with the cursor, when I update |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
898 |
my contents from the model. Allowed arguments are: |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
899 |
#keep / nil -> stay where it was |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
900 |
#endOfLine -> position cursor after the string |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
901 |
#beginOfLine -> position cursor to the beginning |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
902 |
The default is #endOfLine. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
903 |
This may be useful for fields which get new values assigned from |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
904 |
the program (i.e. not from the user)" |
125 | 905 |
|
192 | 906 |
cursorMovementWhenUpdating := aSymbol |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
907 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
908 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
192 | 909 |
! |
910 |
||
911 |
disable |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
912 |
"disable the field; hide the cursor and ignore input" |
192 | 913 |
|
914 |
enabled ifTrue:[ |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
915 |
enabled := false. |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
916 |
self updateBackground. |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
917 |
self hideCursor |
125 | 918 |
] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
919 |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
920 |
"Modified: / 3.8.1998 / 17:52:22 / cg" |
125 | 921 |
! |
922 |
||
192 | 923 |
enable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
924 |
"enable the field; show the cursor and allow input" |
127 | 925 |
|
192 | 926 |
enabled ifFalse:[ |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
927 |
enabled := true. |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
928 |
self updateBackground. |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
929 |
super showCursor |
192 | 930 |
] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
931 |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
932 |
"Modified: / 3.8.1998 / 17:52:18 / cg" |
127 | 933 |
! |
934 |
||
1034 | 935 |
enabled |
936 |
"return true, if the field is enabled (i.e. accepts keyboard input)" |
|
937 |
||
938 |
^ enabled ? true |
|
939 |
||
940 |
! |
|
941 |
||
192 | 942 |
entryCompletionBlock:aOneArgBlock |
943 |
"define an action to be evaluated when Tab (NameCompletion) is pressed. |
|
944 |
The block gets the current contents as argument." |
|
945 |
||
946 |
entryCompletionBlock := aOneArgBlock |
|
125 | 947 |
! |
948 |
||
192 | 949 |
immediateAccept:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
950 |
"set/clear the immediateAccept flag. The default is false. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
951 |
If true, every pressed key immediately accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
952 |
string into the valueHolder (if any)." |
155 | 953 |
|
192 | 954 |
immediateAccept := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
955 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
956 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
192 | 957 |
! |
155 | 958 |
|
995 | 959 |
isAcceptOnLeave |
960 |
"return the acceptOnLeave flag. The default is false. |
|
961 |
If true, leaving the box (via return, cursor etc.) accepts my |
|
962 |
string into the valueHolder (if any). |
|
963 |
(actually, the set of keys can be specified with #leaveKeys:)" |
|
964 |
||
965 |
^ acceptOnLeave |
|
966 |
||
967 |
"Modified: 11.12.1996 / 16:47:25 / cg" |
|
968 |
! |
|
969 |
||
970 |
isAcceptOnLostFocus |
|
971 |
"return the acceptOnLostFocus flag. The default is false. |
|
972 |
If true, a lost focus (via mouse-pointer motion etc.) accepts my |
|
973 |
string into the valueHolder (if any)." |
|
974 |
||
975 |
^ acceptOnLostFocus |
|
976 |
||
977 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
|
978 |
"Created: 11.12.1996 / 16:48:00 / cg" |
|
979 |
! |
|
980 |
||
981 |
isAcceptOnReturn |
|
982 |
"return the acceptOnReturn flag. The default is false. |
|
983 |
If true, leaving the box via return accepts my |
|
984 |
string into the valueHolder (if any)." |
|
985 |
||
986 |
^ acceptOnReturn |
|
987 |
||
988 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
|
989 |
! |
|
990 |
||
991 |
isAcceptOnTab |
|
992 |
"return the acceptOnTab flag. The default is true. |
|
993 |
If true, a pressed Tab key accepts and leaves the box. |
|
994 |
If false, the Tab key is treated like any normal input character |
|
995 |
(i.e. inserted into the contents)." |
|
996 |
||
997 |
^ acceptOnTab |
|
998 |
! |
|
999 |
||
994 | 1000 |
isImmediateAccept |
1001 |
"return the immediateAccept flag. The default is false. |
|
1002 |
If true, every pressed key immediately accepts my |
|
1003 |
string into the valueHolder (if any)." |
|
1004 |
||
1005 |
^ immediateAccept |
|
1006 |
||
1007 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
|
1008 |
! |
|
1009 |
||
192 | 1010 |
leaveAction:aBlock |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1011 |
"define an action to be evaluated when field is left by return or cursor keys. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1012 |
(actually, the set of keys can be specified with #leaveKeys:)" |
192 | 1013 |
|
1014 |
leaveAction := aBlock |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1015 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1016 |
"Modified: 16.12.1995 / 16:26:36 / cg" |
155 | 1017 |
! |
1018 |
||
192 | 1019 |
leaveKeys:aCollectionOfKeySymbols |
1020 |
"define the set of keys which are interpreted as leaveKeys. |
|
1021 |
I.e. those that make the field inactive and accept (if acceptOnLeave is true). |
|
1022 |
The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return." |
|
155 | 1023 |
|
192 | 1024 |
leaveKeys := aCollectionOfKeySymbols |
1025 |
! |
|
155 | 1026 |
|
594 | 1027 |
makeTabable |
1028 |
"arrange for Tab to accept & leave the field |
|
1029 |
If the field is part of a group, the next field gets the |
|
1030 |
input focus" |
|
1031 |
||
1032 |
leaveKeys isNil ifTrue:[ |
|
1033 |
leaveKeys := self class defaultLeaveKeys |
|
1034 |
]. |
|
1035 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1036 |
||
1037 |
"Created: 27.4.1996 / 17:09:48 / cg" |
|
1038 |
! |
|
1039 |
||
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1040 |
readOnly:aBoolean |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1041 |
"make the text readonly or writable" |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1042 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1043 |
super readOnly:aBoolean. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1044 |
self updateBackground. |
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1045 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1046 |
"Created: / 26.7.1998 / 21:23:17 / cg" |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1047 |
"Modified: / 3.8.1998 / 17:52:38 / cg" |
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1048 |
! |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1049 |
|
192 | 1050 |
tabAction:aBlock |
1051 |
"define an action to be evaluated when the tabulator key is pressed." |
|
155 | 1052 |
|
192 | 1053 |
tabAction := aBlock |
594 | 1054 |
! |
1055 |
||
1056 |
tabKey:aKeySymbol |
|
1057 |
"arrange for aKeySymbol to accept & leave the field |
|
1058 |
If the field is part of a group, the next field gets the |
|
1059 |
input focus" |
|
1060 |
||
1061 |
leaveKeys isNil ifTrue:[ |
|
1062 |
leaveKeys := self class defaultLeaveKeys |
|
1063 |
]. |
|
1064 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1065 |
||
1066 |
"Created: 27.4.1996 / 17:08:54 / cg" |
|
187 | 1067 |
! ! |
125 | 1068 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1069 |
!EditField methodsFor:'accessing-channels'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1070 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1071 |
enableChannel |
601 | 1072 |
"return a valueHolder for enable/disable" |
1073 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1074 |
^ enableChannel |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1075 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1076 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1077 |
"Created: 16.12.1995 / 16:29:05 / cg" |
601 | 1078 |
"Modified: 30.4.1996 / 15:09:09 / cg" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1079 |
! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1080 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1081 |
enableChannel:aValueHolder |
601 | 1082 |
"set the valueHolder, which holds the enable boolean value" |
1083 |
||
1372 | 1084 |
|prev| |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1085 |
|
1372 | 1086 |
prev := enableChannel. |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1087 |
enableChannel := aValueHolder. |
1399 | 1088 |
self setupChannel:aValueHolder for:nil withOld:prev |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1089 |
|
1399 | 1090 |
"Modified: / 14.11.1997 / 13:52:44 / cg" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1091 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1092 |
|
187 | 1093 |
!EditField methodsFor:'accessing-contents'! |
125 | 1094 |
|
187 | 1095 |
contents |
1096 |
"return contents as a string |
|
1097 |
- redefined since EditFields hold only one line of text. |
|
1098 |
In your application, please use #editValue; |
|
1099 |
it uses a converter (if any) and is compatible to ST-80." |
|
1100 |
||
1101 |
list isNil ifTrue:[^ '']. |
|
1102 |
(list size == 0) ifTrue:[^ '']. |
|
1103 |
^ list at:1 |
|
1104 |
! |
|
1105 |
||
125 | 1106 |
contents:someText |
1107 |
"set the contents from a string |
|
1108 |
- redefined to place the cursor to the end. |
|
1109 |
In your application, please use #editValue:; |
|
1110 |
it uses a converter (if any) and is compatible to ST-80." |
|
1111 |
||
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1112 |
|newCol txt| |
187 | 1113 |
|
1114 |
newCol := cursorCol. |
|
1115 |
||
1248 | 1116 |
(someText respondsTo:#asString) ifTrue:[ |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1117 |
txt := someText asString |
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1118 |
]. |
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1119 |
super contents:txt. |
125 | 1120 |
|
187 | 1121 |
cursorMovementWhenUpdating == #endOfLine ifTrue:[ |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1122 |
newCol := (txt size + 1). |
187 | 1123 |
] ifFalse:[ |
1179 | 1124 |
cursorMovementWhenUpdating == #beginOfLine ifTrue:[ |
1125 |
newCol := 1 |
|
1126 |
] ifFalse:[ |
|
1127 |
"/ default: stay where it was |
|
1128 |
] |
|
187 | 1129 |
]. |
125 | 1130 |
|
187 | 1131 |
self cursorCol:newCol. |
1179 | 1132 |
|
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1133 |
"Modified: 4.4.1997 / 21:38:24 / cg" |
125 | 1134 |
! |
1135 |
||
192 | 1136 |
converter |
1137 |
"return the converter (if any)." |
|
1138 |
||
1139 |
^ converter |
|
1140 |
! |
|
1141 |
||
1142 |
converter:aConverter |
|
1143 |
"set the converter. If non-nil, |
|
1144 |
the converter is applied to the text to convert from the string |
|
1145 |
representation to the actual object value and vice versa. |
|
1146 |
The default converter is nil, meaning no-conversion |
|
1147 |
(i.e. the edited object is the string itself." |
|
1148 |
||
1149 |
converter := aConverter |
|
1150 |
! |
|
1151 |
||
125 | 1152 |
editValue |
1153 |
"if the field edits a string, this is a name alias for #contents. |
|
1154 |
Otherwise, if there is a converter, return the edited string |
|
1155 |
converted to an appropriate object." |
|
1156 |
||
1157 |
|string| |
|
1158 |
||
1159 |
string := self contents. |
|
279 | 1160 |
string isNil ifTrue:[string := '']. |
125 | 1161 |
converter isNil ifTrue:[^ string]. |
1162 |
^ converter readValueFrom:string |
|
1163 |
! |
|
0 | 1164 |
|
125 | 1165 |
editValue:aStringOrObject |
1166 |
"set the contents. If there is a converter, use it to convert |
|
1167 |
the object into a printed representation. |
|
1168 |
Otherwise, the argument is supposed to be a string like object, |
|
1169 |
and used directly (i.e. this is equivalent to sending #contents:)." |
|
1170 |
||
1171 |
self editValue:aStringOrObject selected:false |
|
0 | 1172 |
! |
1173 |
||
125 | 1174 |
editValue:aStringOrObject selected:aBoolean |
1175 |
"set the contents. If there is a converter, use it to convert |
|
1176 |
the object into a printed representation. |
|
1177 |
Otherwise, the argument is supposed to be a string like object, |
|
187 | 1178 |
and used directly (i.e. this is equivalent to sending #initialText:selected:)." |
125 | 1179 |
|
1180 |
|string| |
|
1181 |
||
1182 |
converter notNil ifTrue:[ |
|
1183 |
string := converter printStringFor:aStringOrObject |
|
1184 |
] ifFalse:[ |
|
1185 |
string := aStringOrObject. |
|
1186 |
]. |
|
1187 |
self contents:string. |
|
1188 |
aBoolean ifTrue:[ |
|
1189 |
self selectFromLine:1 col:1 toLine:1 col:string size |
|
1190 |
] |
|
1191 |
! |
|
1192 |
||
192 | 1193 |
initialText:aString |
1194 |
"set the initialText and select it" |
|
1195 |
||
1196 |
self initialText:aString selected:true |
|
1197 |
! |
|
1198 |
||
187 | 1199 |
initialText:aString selected:aBoolean |
1200 |
"set the initialText and select it if aBoolean is true" |
|
1201 |
||
1202 |
|len s| |
|
125 | 1203 |
|
187 | 1204 |
leftOffset := 0. |
1205 |
(s := aString) notNil ifTrue:[ |
|
1206 |
s := s asString |
|
1207 |
]. |
|
1208 |
self contents:s. |
|
1209 |
aBoolean ifTrue:[ |
|
1210 |
(len := s size) ~~ 0 ifTrue:[ |
|
1211 |
self selectFromLine:1 col:1 toLine:1 col:len |
|
1212 |
] |
|
1213 |
] |
|
1214 |
! |
|
1215 |
||
192 | 1216 |
list:someText |
1217 |
"low level access to the underlying contents' list. |
|
1218 |
Redefined to force text to 1 line, and notify dependents |
|
1219 |
of any changed extent-wishes (for automatic box resizing)." |
|
1220 |
||
1221 |
|l oldWidth| |
|
187 | 1222 |
|
192 | 1223 |
l := someText. |
1224 |
l size > 1 ifTrue:[ |
|
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1225 |
l := OrderedCollection with:(l at:1) |
192 | 1226 |
]. |
1227 |
oldWidth := self widthOfContents. |
|
1228 |
super list:l. |
|
1229 |
self widthOfContents ~~ oldWidth ifTrue:[ |
|
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1230 |
self changedPreferredBounds:nil |
192 | 1231 |
] |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1232 |
|
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1233 |
"Modified: 6.3.1997 / 16:13:36 / cg" |
187 | 1234 |
! |
1235 |
||
1236 |
stringValue |
|
1237 |
"alias for #contents - for compatibility with ST-80's InputField" |
|
1238 |
||
1239 |
^ self contents |
|
1240 |
! ! |
|
1241 |
||
1242 |
!EditField methodsFor:'accessing-look'! |
|
125 | 1243 |
|
155 | 1244 |
maxChars |
1245 |
"return the maximum number of characters that are allowed in |
|
1246 |
the field. |
|
1247 |
A limit of nil means: unlimited. This is the default." |
|
1248 |
||
1249 |
^ lengthLimit |
|
1250 |
||
1251 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
|
1252 |
! |
|
1253 |
||
125 | 1254 |
maxChars:aNumberOrNil |
1255 |
"set the maximum number of characters that are allowed in |
|
1256 |
the field. Additional input will be ignored by the field. |
|
1034 | 1257 |
A limit of nil or zero means: unlimited. This is the default. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1258 |
If set, a lengthLimit must be defined before any contents is placed |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1259 |
into the field, because the contents is not cut when the max is |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1260 |
changed later. I.e. it should be set early after creation of the field. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1261 |
|
125 | 1262 |
This method has been renamed from #lengthLimit: for ST-80 |
1263 |
compatibility." |
|
1264 |
||
1034 | 1265 |
aNumberOrNil == 0 ifTrue:[ |
1266 |
lengthLimit := nil |
|
1267 |
] ifFalse:[ |
|
1268 |
lengthLimit := aNumberOrNil. |
|
1269 |
] |
|
187 | 1270 |
! |
1271 |
||
192 | 1272 |
passwordCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1273 |
"return the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1274 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1275 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1276 |
|
192 | 1277 |
^ passwordCharacter |
0 | 1278 |
|
192 | 1279 |
"Modified: 6.9.1995 / 12:25:39 / claus" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1280 |
"Modified: 16.12.1995 / 16:24:25 / cg" |
125 | 1281 |
! |
1282 |
||
192 | 1283 |
passwordCharacter:aCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1284 |
"set the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1285 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1286 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1287 |
|
192 | 1288 |
passwordCharacter := aCharacter |
97 | 1289 |
|
192 | 1290 |
"Modified: 6.9.1995 / 12:25:33 / claus" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1291 |
"Modified: 16.12.1995 / 16:24:33 / cg" |
38 | 1292 |
! ! |
1293 |
||
1399 | 1294 |
!EditField methodsFor:'change & update'! |
1295 |
||
1296 |
update:something with:aParameter from:changedObject |
|
1297 |
changedObject == enableChannel ifTrue:[ |
|
1298 |
self enableStateChange. |
|
1299 |
^ self |
|
1300 |
]. |
|
1301 |
super update:something with:aParameter from:changedObject |
|
1302 |
||
1303 |
"Created: / 14.11.1997 / 13:52:31 / cg" |
|
1304 |
! ! |
|
1305 |
||
0 | 1306 |
!EditField methodsFor:'cursor drawing'! |
1307 |
||
155 | 1308 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
1309 |
startVisLineNr to:endVisLineNr do:[:visLine | |
|
1310 |
self drawVisibleLine:visLine with:fg and:bg |
|
1311 |
] |
|
1312 |
||
1313 |
"Modified: 6.9.1995 / 12:24:29 / claus" |
|
1314 |
! |
|
1315 |
||
0 | 1316 |
showCursor |
1317 |
"make cursor visible if currently invisible - but only if this |
|
1318 |
EditField is enabled" |
|
1319 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
1320 |
(enabled and:[self isReadOnly not]) ifTrue:[super showCursor] |
1616
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1321 |
|
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1322 |
"Modified: / 28.7.1998 / 11:32:04 / cg" |
0 | 1323 |
! ! |
1324 |
||
1325 |
!EditField methodsFor:'cursor movement'! |
|
1326 |
||
1327 |
cursorDown |
|
1328 |
"catch cursor movement" |
|
1329 |
||
1330 |
(cursorVisibleLine == nLinesShown) ifFalse:[ |
|
59 | 1331 |
super cursorDown |
0 | 1332 |
] |
192 | 1333 |
! |
1334 |
||
1335 |
cursorLine:line col:col |
|
1336 |
"catch cursor movement" |
|
1337 |
||
1338 |
super cursorLine:1 col:col |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1339 |
! |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1340 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1341 |
validateCursorCol:col inLine:line |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1342 |
"check of col is a valid cursor position; |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1343 |
return a fixed value if not." |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1344 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1345 |
|sz| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1346 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1347 |
sz := self contents size. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1348 |
lengthLimit notNil ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1349 |
sz := sz min:lengthLimit. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1350 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1351 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1352 |
col <= sz ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1353 |
^ col |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1354 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1355 |
^ sz + 1. "/ to allow positioning right behind the string |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1356 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1357 |
"Created: 22.5.1996 / 18:17:27 / cg" |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1358 |
"Modified: 22.5.1996 / 18:19:04 / cg" |
192 | 1359 |
! ! |
1360 |
||
1361 |
!EditField methodsFor:'editing'! |
|
1362 |
||
1363 |
paste:someText |
|
1364 |
"redefined to force text to 1 line" |
|
1365 |
||
1366 |
super paste:someText. |
|
1367 |
list size > 1 ifTrue:[ |
|
1368 |
self deleteFromLine:2 toLine:(list size) |
|
1369 |
] |
|
0 | 1370 |
! ! |
1371 |
||
70 | 1372 |
!EditField methodsFor:'event handling'! |
19 | 1373 |
|
192 | 1374 |
buttonPress:button x:x y:y |
1375 |
"enable myself on mouse click" |
|
1376 |
||
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1377 |
|prevFocus| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1378 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1379 |
enabled ifFalse:[^ self]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1380 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1381 |
prevFocus := hasKeyboardFocus. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1382 |
clickAction notNil ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1383 |
clickAction value:self |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1384 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1385 |
hasKeyboardFocus ~~ prevFocus ifTrue:[ |
333 | 1386 |
^ self |
1387 |
]. |
|
1388 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1389 |
super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1390 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1391 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1392 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1393 |
"/ super buttonPress:button x:x y:y. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1394 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1395 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1396 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1397 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1398 |
"/ super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1399 |
"/ ] |
333 | 1400 |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1401 |
"Modified: 22.5.1996 / 15:02:45 / cg" |
192 | 1402 |
! |
1403 |
||
1404 |
canHandle:aKey |
|
1405 |
"return true, if the receiver would like to handle aKey |
|
1406 |
(usually from another view, when the receiver is part of |
|
1407 |
a more complex dialog box). |
|
1408 |
We do return true here, since the editfield will handle |
|
1409 |
all keys. |
|
1410 |
OBSOLETE: dont use this anymore - its a leftover for the tableWidget" |
|
1411 |
||
1412 |
^ true |
|
1413 |
! |
|
1414 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1415 |
enableStateChange |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1416 |
enableChannel value ifTrue:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1417 |
self enable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1418 |
] ifFalse:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1419 |
self disable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1420 |
]. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1421 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1422 |
"Created: 16.12.1995 / 16:35:39 / cg" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1423 |
"Modified: 16.12.1995 / 16:36:13 / cg" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1424 |
! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1425 |
|
192 | 1426 |
focusIn |
1427 |
"got the explicit focus" |
|
1428 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1429 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1430 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1431 |
"/ super focusIn. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1432 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1433 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1434 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1435 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1436 |
"/ super focusIn |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1437 |
"/ ]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1438 |
^ super focusIn |
192 | 1439 |
! |
1440 |
||
892 | 1441 |
hasKeyboardFocus:aBoolean |
1442 |
aBoolean ifFalse:[ |
|
1443 |
acceptOnLostFocus ifTrue:[ |
|
1407
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1444 |
model notNil ifTrue:[ |
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1445 |
model value = self argForChangeMessage ifTrue:[ |
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1446 |
^ self |
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1447 |
] |
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1448 |
]. |
892 | 1449 |
self accept. |
1450 |
]. |
|
1451 |
]. |
|
1452 |
super hasKeyboardFocus:aBoolean |
|
1453 |
||
1407
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1454 |
"Created: / 11.12.1996 / 16:57:50 / cg" |
e550dd1f3b24
onLostFocus: only accept if there was a change
Claus Gittinger <cg@exept.de>
parents:
1399
diff
changeset
|
1455 |
"Modified: / 6.12.1997 / 14:07:12 / cg" |
892 | 1456 |
! |
1457 |
||
125 | 1458 |
keyPress:key x:x y:y |
1459 |
"if keyHandler is defined, pass input; otherwise check for leave |
|
1460 |
keys" |
|
1461 |
||
490 | 1462 |
<resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
922 | 1463 |
#DeleteLine #GotoLine #EndOfLine #EndOfText |
1464 |
#CursorDown #CursorUp)> |
|
132 | 1465 |
|
1282 | 1466 |
|leave oldContents newContents| |
125 | 1467 |
|
1468 |
enabled ifFalse:[ |
|
325 | 1469 |
^ self |
125 | 1470 |
]. |
1471 |
||
1472 |
(key == #DeleteLine) ifTrue:[ |
|
325 | 1473 |
Smalltalk at:#CopyBuffer put:(self contents). |
1474 |
self contents:''. ^ self |
|
125 | 1475 |
]. |
19 | 1476 |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1477 |
leave := leaveKeys includes:key. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1478 |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1479 |
(key == entryCompletionCharacter |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1480 |
and:[entryCompletionBlock notNil]) ifTrue:[ |
979 | 1481 |
oldContents := self contents. |
1482 |
oldContents isNil ifTrue:[ |
|
1483 |
oldContents := '' |
|
1484 |
] ifFalse:[ |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1485 |
oldContents := oldContents asString |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1486 |
]. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1487 |
|
979 | 1488 |
entryCompletionBlock value:oldContents. |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1489 |
|
979 | 1490 |
newContents := self contents. |
1491 |
newContents isNil ifTrue:[ |
|
1492 |
newContents := '' |
|
1493 |
] ifFalse:[ |
|
1494 |
newContents := newContents asString |
|
1495 |
]. |
|
1496 |
newContents ~= oldContents ifTrue:[ |
|
1497 |
self textChanged |
|
1498 |
]. |
|
1499 |
^ self |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1500 |
]. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1501 |
|
125 | 1502 |
(key == #Tab) ifTrue:[ |
964
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1503 |
tabAction notNil ifTrue:[ |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1504 |
"/ tab-hook. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1505 |
acceptOnTab ifTrue:[ |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1506 |
self accept. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1507 |
]. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1508 |
tabAction value. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1509 |
^ self |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1510 |
]. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1511 |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1512 |
acceptOnTab ifTrue:[ |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1513 |
self accept. |
325 | 1514 |
]. |
594 | 1515 |
leave ifFalse:[ |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1516 |
"/ forward it as a Focus-step |
1061
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1517 |
self sensor shiftDown ifTrue:[ |
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1518 |
^ super keyPress:#FocusPrevious x:x y:y |
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1519 |
] ifFalse:[ |
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1520 |
^ super keyPress:#FocusNext x:x y:y |
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1521 |
] |
594 | 1522 |
] |
125 | 1523 |
]. |
480 | 1524 |
|
125 | 1525 |
(key == #Return) ifTrue:[ |
964
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1526 |
crAction notNil ifTrue:[ |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1527 |
"/ cr-hook. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1528 |
acceptOnReturn ifTrue:[ |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1529 |
self accept. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1530 |
]. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1531 |
crAction value. |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1532 |
^ self |
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1533 |
]. |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1534 |
leave ifFalse:[ |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1535 |
"/ forward it as a Focus-step |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1536 |
^ super keyPress:#FocusNext x:x y:y |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1537 |
] |
125 | 1538 |
]. |
480 | 1539 |
|
125 | 1540 |
leave ifTrue:[ |
325 | 1541 |
((key == #Return and:[acceptOnReturn]) |
480 | 1542 |
or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[ |
325 | 1543 |
self accept. |
1544 |
]. |
|
279 | 1545 |
|
325 | 1546 |
leaveAction notNil ifTrue:[ |
1547 |
^ leaveAction value:key |
|
1548 |
]. |
|
125 | 1549 |
|
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1550 |
(x notNil and:[x >= 0]) ifTrue:[ |
325 | 1551 |
" |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1552 |
we do not handle this key directly. |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1553 |
let superview know about the key that caused us to leave (maybe RETURN, DOWN, UP etc.... |
325 | 1554 |
" |
1555 |
(superView notNil and:[superView canHandle:key from:self]) ifTrue:[ |
|
1556 |
superView keyPress:key x:x y:y. |
|
1557 |
]. |
|
1558 |
]. |
|
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1559 |
|
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1560 |
"/ a leave, but no action defined |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1561 |
"/ forward it as a Focus-step |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1562 |
key == #CursorDown ifTrue:[ |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1563 |
"/ forward it as a Focus-step |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1564 |
^ super keyPress:#FocusNext x:x y:y |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1565 |
]. |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1566 |
key == #CursorUp ifTrue:[ |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1567 |
"/ forward it as a Focus-step |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1568 |
^ super keyPress:#FocusPrevious x:x y:y |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1569 |
]. |
325 | 1570 |
^ self |
19 | 1571 |
]. |
121 | 1572 |
|
125 | 1573 |
" |
1574 |
ignore some keys (if not a leaveKey) ... |
|
1575 |
" |
|
1576 |
(key == #Find) ifTrue:[^self]. |
|
1577 |
(key == #FindNext) ifTrue:[^self]. |
|
1578 |
(key == #FindPrev) ifTrue:[^self]. |
|
1579 |
(key == #GotoLine) ifTrue:[^self]. |
|
1580 |
||
1581 |
" |
|
1582 |
a normal key - let superclass's method insert it |
|
1583 |
" |
|
1584 |
super keyPress:key x:x y:y. |
|
1585 |
||
1586 |
" |
|
1587 |
for end-of-text, also move to end-of-line |
|
1588 |
" |
|
1589 |
key == #EndOfText ifTrue:[ |
|
325 | 1590 |
super keyPress:#EndOfLine x:x y:y. |
125 | 1591 |
]. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1592 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1593 |
self resizeOrScroll. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1594 |
|
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1595 |
"Modified: 2.5.1996 / 17:24:16 / stefan" |
1061
eef045108fe0
oops - Shift-TAB is focusPrevious; not focusNext.
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
1596 |
"Modified: 26.2.1997 / 00:14:06 / cg" |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1597 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1598 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1599 |
resizeOrScroll |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1600 |
"helper for keyPress. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1601 |
Extracted for easier subclass redefinition." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1602 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1603 |
|xCol newOffset newWidth| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1604 |
|
125 | 1605 |
newWidth := self widthOfContents. |
1606 |
||
1607 |
" |
|
1608 |
should (& can) we resize ? |
|
1609 |
" |
|
1610 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
|
1611 |
(xCol > (width * (5/6))) ifTrue:[ |
|
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1612 |
self changedPreferredBounds:nil |
125 | 1613 |
] ifFalse:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1614 |
newWidth < (width * (1/6)) ifTrue:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1615 |
self changedPreferredBounds:nil |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1616 |
] |
125 | 1617 |
]. |
1618 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1619 |
autoScrollHorizontally ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1620 |
" |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1621 |
did someone react (i.e. has my extent changed) ? |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1622 |
(if not, we scroll horizontally) |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1623 |
" |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1624 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1625 |
(xCol > (width * (5/6))) ifTrue:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1626 |
newOffset := leftOffset + (width // 2). |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1627 |
] ifFalse:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1628 |
(xCol < (width * (1/6))) ifTrue:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1629 |
newOffset := 0 max: leftOffset - (width // 2). |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1630 |
] ifFalse:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1631 |
newOffset := leftOffset |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1632 |
] |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1633 |
]. |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1634 |
newOffset ~~ leftOffset ifTrue:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1635 |
self scrollHorizontalTo:newOffset. |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1636 |
] |
125 | 1637 |
]. |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1638 |
|
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1639 |
"Modified: 6.3.1997 / 16:13:59 / cg" |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1640 |
! |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1641 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1642 |
showFocus:explicit |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1643 |
"/ giving me the focus is loke clicking on me |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1644 |
"/ (tell my enterFieldGroup .... |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1645 |
|
343
a7b6fbfdc453
oops - explicit focusChange was broken
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1646 |
(enabled or:[explicit]) ifTrue:[ |
333 | 1647 |
clickAction notNil ifTrue:[clickAction value:self]. |
1648 |
self showCursor. |
|
1649 |
super showFocus:explicit |
|
1650 |
] |
|
1651 |
||
343
a7b6fbfdc453
oops - explicit focusChange was broken
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1652 |
"Modified: 9.2.1996 / 20:49:48 / cg" |
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1653 |
! |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1654 |
|
1683
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1655 |
showNoFocus:explicit |
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1656 |
self hideCursor. |
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1657 |
super showNoFocus:explicit |
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1658 |
|
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1659 |
"Modified: / 17.9.1998 / 15:10:04 / cg" |
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1660 |
! |
48afbdaa32d5
hide cursor when focus is lost
Claus Gittinger <cg@exept.de>
parents:
1654
diff
changeset
|
1661 |
|
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1662 |
sizeChanged:how |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1663 |
"scroll to origin, if all fits" |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1664 |
|
1282 | 1665 |
|xCol| |
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1666 |
|
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1667 |
leftOffset ~~ 0 ifTrue:[ |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1668 |
xCol := self xOfCol:cursorCol inVisibleLine:cursorLine. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1669 |
(xCol < (width * (5/6))) ifTrue:[ |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1670 |
self scrollHorizontalTo:0 |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1671 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1672 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1673 |
self makeCursorVisible. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1674 |
super sizeChanged:how |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1675 |
|
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1676 |
"Modified: 10.7.1996 / 10:59:37 / cg" |
192 | 1677 |
! ! |
1678 |
||
1679 |
!EditField methodsFor:'initialization'! |
|
1680 |
||
1399 | 1681 |
destroy |
1682 |
enableChannel notNil ifTrue:[ |
|
1683 |
enableChannel removeDependent:self. |
|
1684 |
enableChannel := nil. |
|
1685 |
]. |
|
1686 |
super destroy |
|
1687 |
||
1688 |
"Created: / 14.11.1997 / 13:53:50 / cg" |
|
1689 |
"Modified: / 14.11.1997 / 13:58:49 / cg" |
|
1690 |
! |
|
1691 |
||
192 | 1692 |
editMenu |
1054 | 1693 |
"return a popUpMenu for the receiver" |
1694 |
||
725 | 1695 |
<resource: #keyboard ( #Accept #Copy #Cut #Paste ) > |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1248
diff
changeset
|
1696 |
<resource: #programMenu> |
1054 | 1697 |
|
725 | 1698 |
|
1547
57b45c785615
use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents:
1544
diff
changeset
|
1699 |
|items m| |
192 | 1700 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
1701 |
self isReadOnly == true ifTrue:[ |
1616
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1702 |
items := #( |
1547
57b45c785615
use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents:
1544
diff
changeset
|
1703 |
('copy' copySelection Copy ) |
1616
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1704 |
) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1705 |
] ifFalse:[ |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1706 |
items := #( |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1707 |
('copy' copySelection Copy ) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1708 |
('cut' cut Cut ) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1709 |
('paste' pasteOrReplace Paste ) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1710 |
). |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1711 |
(acceptAction notNil |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1712 |
or:[model notNil and:[changeMsg notNil]]) ifTrue:[ |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1713 |
immediateAccept ifFalse:[ |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1714 |
items := items , #( |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1715 |
('-' ) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1716 |
('accept' accept Accept) |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1717 |
). |
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1718 |
]. |
677
5cacd1adea6a
no <accept> menu if immediateAccept is on
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
1719 |
]. |
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1720 |
]. |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1721 |
|
1547
57b45c785615
use new menu-creation message.
Claus Gittinger <cg@exept.de>
parents:
1544
diff
changeset
|
1722 |
m := PopUpMenu itemList:items resources:resources. |
192 | 1723 |
|
1724 |
self hasSelection ifFalse:[ |
|
333 | 1725 |
m disableAll:#(copySelection cut) |
1726 |
]. |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
1727 |
(enabled not or:[self isReadOnly]) ifTrue:[ |
1616
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1728 |
m disableAll:#(cut pasteOrReplace accept) |
192 | 1729 |
]. |
1730 |
||
1731 |
^ m |
|
333 | 1732 |
|
1616
92c7be73028f
hide some menu items and cursor if readOnly
Claus Gittinger <cg@exept.de>
parents:
1609
diff
changeset
|
1733 |
"Modified: / 28.7.1998 / 11:35:41 / cg" |
19 | 1734 |
! |
0 | 1735 |
|
192 | 1736 |
initStyle |
967 | 1737 |
"setup viewStyle specifics" |
1738 |
||
1478
97296faf0c2f
make certain that bg-color is not dithered.
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1739 |
|bg| |
97296faf0c2f
make certain that bg-color is not dithered.
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1740 |
|
192 | 1741 |
super initStyle. |
1742 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
1743 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device] |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
1744 |
|
192 | 1745 |
DefaultBackgroundColor notNil ifTrue:[ |
967 | 1746 |
bgColor := DefaultBackgroundColor on:device. |
1482 | 1747 |
"/ bgColor ditherForm notNil ifTrue:[ |
1748 |
"/ bgColor := (bgColor copy) exactOrNearestOn:device |
|
1749 |
"/ ]. |
|
967 | 1750 |
self viewBackground:bgColor. |
192 | 1751 |
]. |
1752 |
fgColor := DefaultForegroundColor. |
|
1753 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
1754 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
967 | 1755 |
|
1544
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
1756 |
"/ enable this, when the focus detection works correctly (in dialogs) |
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
1757 |
"/ cursorTypeNoFocus := #none |
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
1758 |
|
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
1759 |
"Modified: / 21.5.1998 / 15:38:14 / cg" |
192 | 1760 |
! |
0 | 1761 |
|
192 | 1762 |
initialize |
1763 |
super initialize. |
|
832 | 1764 |
self initialHeight:(font height + font descent + (topMargin * 2)). |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1765 |
|
192 | 1766 |
nFullLinesShown := 1. |
1767 |
nLinesShown := 1. |
|
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
1768 |
trimBlankLines := immediateAccept := acceptOnLostFocus := false. |
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
1769 |
enabled := fixedSize := autoScrollHorizontally := true. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1770 |
acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
192 | 1771 |
cursorShown := true. |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1772 |
entryCompletionCharacter := #Tab. |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1773 |
|
594 | 1774 |
leaveKeys isNil ifTrue:[ |
1775 |
leaveKeys := self class defaultLeaveKeys. |
|
1776 |
]. |
|
192 | 1777 |
cursorMovementWhenUpdating := #endOfLine |
594 | 1778 |
|
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
1779 |
"Modified: 20.5.1997 / 19:00:49 / cg" |
192 | 1780 |
! ! |
1781 |
||
1782 |
!EditField methodsFor:'private'! |
|
1783 |
||
1784 |
argForChangeMessage |
|
1785 |
"redefined to send use converted value (if I have one)" |
|
1786 |
||
1787 |
^ self editValue |
|
1788 |
! |
|
1789 |
||
1790 |
getListFromModel |
|
1791 |
"redefined to aquire the text via the aspectMsg - not the listMsg, |
|
1792 |
and to ignore updates resulting from my own change." |
|
1793 |
||
1464 | 1794 |
|val| |
1795 |
||
192 | 1796 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
1464 | 1797 |
aspectMsg == #value ifTrue:[ |
1798 |
val := model value |
|
1799 |
] ifFalse:[ |
|
1800 |
val := model perform:aspectMsg |
|
1801 |
]. |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1802 |
|
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1803 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1804 |
ignore updates from my own change |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1805 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1806 |
lockUpdates ifTrue:[ |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1807 |
lockUpdates := false. |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1808 |
val = self editValue ifTrue:[ |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1809 |
^ self |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1810 |
] |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1811 |
]. |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1812 |
|
1464 | 1813 |
self editValue:val. |
0 | 1814 |
] |
1464 | 1815 |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
1816 |
"Modified: / 23.4.1998 / 10:10:37 / cg" |
0 | 1817 |
! |
1818 |
||
192 | 1819 |
startAutoScrollDown:y |
1820 |
"no vertical scrolling in editfields" |
|
1821 |
||
1822 |
^ self |
|
1823 |
! |
|
1824 |
||
1825 |
startAutoScrollUp:y |
|
1826 |
"no vertical scrolling in editfields" |
|
1827 |
||
1828 |
^ self |
|
1829 |
! |
|
0 | 1830 |
|
192 | 1831 |
textChanged |
1832 |
"this is sent by mySelf (somewhere in a superclass) whenever |
|
1833 |
my contents has changed. |
|
1834 |
A good place to add immediateAccept functionality and check for the |
|
1835 |
lengthLimit." |
|
1836 |
||
1837 |
|string c| |
|
1838 |
||
1839 |
super textChanged. |
|
1840 |
string := self contents. |
|
1841 |
lengthLimit notNil ifTrue:[ |
|
1842 |
string size > lengthLimit ifTrue:[ |
|
1843 |
c := cursorCol. |
|
1844 |
self contents:(string copyTo:lengthLimit). |
|
1845 |
self flash. |
|
1846 |
self cursorCol:c. |
|
125 | 1847 |
] |
0 | 1848 |
]. |
192 | 1849 |
immediateAccept ifTrue:[ |
1850 |
self accept |
|
1851 |
] |
|
105 | 1852 |
! |
1853 |
||
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1854 |
updateBackground |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1855 |
"make my background grey, whenever either readOnly or disable" |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1856 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
1857 |
(self isReadOnly or:[enabled not]) ifTrue:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1858 |
self backgroundColor:(View defaultViewBackgroundColor). |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1859 |
enabled ifFalse:[ |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1860 |
self foregroundColor:(StyleSheet colorAt:'button.disabledForegroundColor' default:Color gray). |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1861 |
] |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1862 |
] ifFalse:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1863 |
self backgroundColor:DefaultBackgroundColor. |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1864 |
self foregroundColor:DefaultForegroundColor. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1865 |
] |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1866 |
|
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
1867 |
"Modified: / 3.8.1998 / 18:40:11 / cg" |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1868 |
! |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1869 |
|
192 | 1870 |
visibleAt:visLineNr |
1871 |
"return the string at lineNr for display. |
|
1872 |
If there is a password character, return a string consisting of those only." |
|
1873 |
||
1874 |
|s| |
|
105 | 1875 |
|
192 | 1876 |
s := super visibleAt:visLineNr. |
1877 |
passwordCharacter notNil ifTrue:[ |
|
1878 |
^ String new:(s size) withAll:passwordCharacter |
|
1879 |
]. |
|
1880 |
^ s |
|
1881 |
||
1882 |
"Modified: 6.9.1995 / 12:25:06 / claus" |
|
0 | 1883 |
! ! |
125 | 1884 |
|
192 | 1885 |
!EditField methodsFor:'queries'! |
1886 |
||
561 | 1887 |
isInputField |
1888 |
"return true, if the receiver is some kind of input view, |
|
1889 |
i.e. it should (can) be part of an enterGroup. |
|
1890 |
Return true here" |
|
1891 |
||
1892 |
^ true |
|
1893 |
||
1894 |
"Created: 4.3.1996 / 11:32:34 / cg" |
|
1895 |
! |
|
1896 |
||
192 | 1897 |
preferredExtent |
1898 |
"return the preferred extent of this view. |
|
1899 |
That is the width of the string plus some extra, |
|
1900 |
but not wider than half of the screen" |
|
1901 |
||
1120 | 1902 |
|string w h f| |
125 | 1903 |
|
800 | 1904 |
"/ If I have an explicit preferredExtent .. |
1905 |
||
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
1906 |
preferredExtent notNil ifTrue:[ |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
1907 |
^ preferredExtent |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
1908 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
1909 |
|
192 | 1910 |
string := self contents. |
1911 |
(string isNil or:[string isBlank]) ifTrue:[ |
|
667
d02f6bba8fc5
use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents:
660
diff
changeset
|
1912 |
string := ' ' "/ just any string is ok ^ super preferredExtent |
192 | 1913 |
]. |
1914 |
f := font on:device. |
|
1915 |
w := ((f widthOf:string) * 1.5) rounded. |
|
1120 | 1916 |
w := w + margin + margin. |
192 | 1917 |
w := w min:(device width // 2). |
667
d02f6bba8fc5
use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents:
660
diff
changeset
|
1918 |
|
1542
5778dd813273
default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
1919 |
h := f maxHeight + (f maxDescent * 2) + (margin * 2). |
1120 | 1920 |
|
1921 |
^ w rounded @ h rounded |
|
192 | 1922 |
|
1542
5778dd813273
default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
1923 |
"Modified: / 6.9.1995 / 19:24:06 / claus" |
5778dd813273
default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
1924 |
"Modified: / 21.5.1998 / 02:13:35 / cg" |
192 | 1925 |
! |
1926 |
||
1927 |
specClass |
|
1372 | 1928 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditFieldSpec)" |
1929 |
||
192 | 1930 |
self class == EditField ifTrue:[^ InputFieldSpec]. |
1047 | 1931 |
^ super specClass |
125 | 1932 |
|
1372 | 1933 |
"Modified: / 5.9.1995 / 17:28:27 / claus" |
1934 |
"Modified: / 31.10.1997 / 19:48:59 / cg" |
|
325 | 1935 |
! |
1936 |
||
1937 |
tabMeansNextField |
|
1938 |
"return true, if Tab character should shift focus to the next field" |
|
1939 |
||
1940 |
"if I have a completionBlock, I want my Tabs ..." |
|
1941 |
||
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1942 |
^ entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab] |
325 | 1943 |
|
1944 |
"Created: 7.2.1996 / 19:16:38 / cg" |
|
192 | 1945 |
! ! |
1946 |
||
1947 |
!EditField methodsFor:'realization'! |
|
1948 |
||
1274 | 1949 |
realize |
192 | 1950 |
"scroll back to beginning when realized" |
1268 | 1951 |
|
192 | 1952 |
leftOffset := 0. |
1274 | 1953 |
super realize |
1268 | 1954 |
|
1274 | 1955 |
"Created: 24.7.1997 / 18:23:15 / cg" |
125 | 1956 |
! ! |
192 | 1957 |
|
1958 |
!EditField methodsFor:'scrolling'! |
|
1959 |
||
1960 |
makeColVisible:col inLine:line |
|
1961 |
"dont scroll for the cursor, if its behond the text and a lengthLimit |
|
1962 |
is present." |
|
1963 |
||
1964 |
lengthLimit notNil ifTrue:[ |
|
1965 |
(col == cursorCol and:[col > lengthLimit]) ifTrue:[ |
|
1966 |
^ super makeColVisible:lengthLimit inLine:line |
|
1967 |
] |
|
1968 |
]. |
|
1969 |
^ super makeColVisible:col inLine:line |
|
1970 |
||
1971 |
"Modified: 6.9.1995 / 13:57:53 / claus" |
|
1972 |
! ! |
|
1973 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1974 |
!EditField methodsFor:'selections'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1975 |
|
1080
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1976 |
selectAll |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1977 |
"select the whole text. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1978 |
redefined to send super selectFrom... since we dont want the |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1979 |
cursor to be moved in this case." |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1980 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1981 |
|len| |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1982 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1983 |
list isNil ifTrue:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1984 |
self unselect |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1985 |
] ifFalse:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1986 |
len := (self listAt:1) size. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1987 |
len ~~ 0 ifTrue:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1988 |
super selectFromLine:1 col:1 toLine:1 col:len. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1989 |
]. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1990 |
typeOfSelection := nil |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1991 |
] |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1992 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1993 |
"Modified: 28.2.1997 / 19:16:21 / cg" |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1994 |
! |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1995 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1996 |
validateNewSelection |
1654 | 1997 |
"make certain that only one line is ever selected" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1998 |
|
1654 | 1999 |
selectionEndLine notNil ifTrue:[ |
2000 |
selectionEndLine > 1 ifTrue:[ |
|
2001 |
selectionEndLine := 2. selectionEndCol := 0 |
|
2002 |
] |
|
2003 |
]. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2004 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2005 |
|
892 | 2006 |
!EditField class methodsFor:'documentation'! |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2007 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2008 |
version |
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
2009 |
^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.115 1999-02-09 18:28:22 cg Exp $' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2010 |
! ! |