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