author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:36:01 +0200 | |
changeset 582 | e151eeae2c9a |
parent 575 | fe3c389931f7 |
child 586 | 032b3245e53a |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 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 |
PopUpView subclass:#PopUpMenu |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
14 |
instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
15 |
actionLines actionValues hideOnRelease defaultHideOnRelease' |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
16 |
classVariableNames:'DefaultHideOnRelease' |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
17 |
poolDictionaries:'' |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
18 |
category:'Views-Menus' |
0 | 19 |
! |
20 |
||
38 | 21 |
!PopUpMenu class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 26 |
All Rights Reserved |
38 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
This class provides PopUpMenu functionality; Actually, this class |
|
40 |
only provides the popup and shadow functionality and wraps another |
|
41 |
view, which is the actual menu-list (usually an instance of MenuView). |
|
42 |
||
43 |
PopUpMenus are usually created with a list of labels, selectors and a |
|
44 |
receivier. Once activated, the specified receiver will be sent a |
|
45 |
'selector'-message. |
|
112 | 46 |
|
47 |
PopupMenus may be either assigned statically to a view (via the #middleButtonMenu: |
|
48 |
message) or created dynamically as required. |
|
49 |
Static definition makes sense, if the menu stays constant and you want to |
|
50 |
assign it once for the lifetime of the view. |
|
51 |
||
52 |
Dynamic menus are easier to use, if the number of or look of the entries has to |
|
53 |
change according the internal state of some model. Also, this is the ST-80 way |
|
54 |
of using popupMenus. For dynamic popups, the views model is asked for a menu |
|
55 |
via the #menuSelector each time a button press occurs. |
|
56 |
||
57 |
See examples section for more. |
|
63 | 58 |
" |
59 |
! |
|
38 | 60 |
|
63 | 61 |
examples |
62 |
" |
|
284 | 63 |
|
38 | 64 |
Examples: |
65 |
||
284 | 66 |
|p| |
67 |
p := PopUpMenu |
|
68 |
labels:#('foo' |
|
69 |
'bar' |
|
70 |
'baz') |
|
71 |
selectors:#( |
|
72 |
#foo |
|
73 |
#bar |
|
74 |
#baz) |
|
75 |
receiver:nil. |
|
76 |
p showAtPointer |
|
38 | 77 |
|
78 |
||
459 | 79 |
dynamic with action instead of selector being sent: |
80 |
|p| |
|
81 |
||
82 |
p := PopUpMenu |
|
83 |
labels:(($a to: $d) collect:[:char | char asString]) |
|
84 |
selectors:nil |
|
85 |
receiver:nil. |
|
86 |
p action:[:idx | Transcript showCr:'selected index is '; showCr:idx]. |
|
87 |
p showAtPointer |
|
88 |
||
89 |
||
545 | 90 |
individual actions: |
91 |
|p| |
|
92 |
p := PopUpMenu |
|
93 |
labels:#('foo' |
|
94 |
'bar' |
|
95 |
'baz') |
|
96 |
selectors:#( |
|
97 |
#foo |
|
98 |
#bar |
|
99 |
#baz). |
|
100 |
p actionAt:#foo put:[Transcript showCr:'foo']. |
|
101 |
p actionAt:#bar put:[Transcript showCr:'bar']. |
|
102 |
p actionAt:#baz put:[Transcript showCr:'baz']. |
|
103 |
p showAtPointer |
|
104 |
||
38 | 105 |
sometimes, you want to specify both selectors and some arguments |
106 |
to be sent; this is done by: |
|
107 |
||
284 | 108 |
|p| |
109 |
p := PopUpMenu |
|
110 |
labels:#('foo' 'bar' 'baz') |
|
111 |
selectors:#(#foo: #bar: #foo:) |
|
112 |
args:#(1 2 3) |
|
113 |
receiver:nil. |
|
114 |
p showAtPointer |
|
38 | 115 |
|
116 |
or, the same selector but different arguments: |
|
117 |
||
284 | 118 |
|p| |
119 |
p := PopUpMenu |
|
120 |
labels:#('foo' 'bar' 'baz') |
|
121 |
selectors:#foo: |
|
122 |
args:#(1 2 3) |
|
123 |
receiver:nil. |
|
124 |
p showAtPointer |
|
38 | 125 |
|
126 |
Normally, you do not show the menu explicitely, but install |
|
112 | 127 |
it as a either as middleButtonMenu of some view or return it from |
128 |
a model. |
|
129 |
(Views/Controllers button-event handler will show it when the middle |
|
130 |
button is pressed ...) |
|
131 |
Static menu: |
|
38 | 132 |
|
284 | 133 |
|v m| |
38 | 134 |
|
284 | 135 |
v := View new. |
136 |
m := PopUpMenu |
|
137 |
labels:#('lower' |
|
138 |
'raise' |
|
139 |
'-' |
|
140 |
'destroy') |
|
141 |
selectors:#(#lower #raise nil #destroy) |
|
142 |
receiver:v. |
|
143 |
v middleButtonMenu:m. |
|
144 |
v open |
|
38 | 145 |
|
112 | 146 |
Dynamic menu: |
147 |
(since we need some model which responds to a menu-message, |
|
148 |
we use a plug in the example below; normally, this would be your model) |
|
149 |
||
284 | 150 |
|v model| |
112 | 151 |
|
284 | 152 |
model := Plug new. |
153 |
model respondTo:#getMenu with:[PopUpMenu labels:#('foo' 'bar') |
|
154 |
selectors:#(foo bar)]. |
|
155 |
model respondTo:#foo with:[Transcript showCr:'models foo called']. |
|
156 |
model respondTo:#bar with:[Transcript showCr:'models bar called']. |
|
112 | 157 |
|
284 | 158 |
v := View new. |
159 |
v model:model; menu:#getMenu. |
|
160 |
v open |
|
112 | 161 |
|
162 |
Dynamic menus are the MVC-way (i.e. ST-80) way of doing things. |
|
163 |
They are usually easier to use, if the menu changes depending on the models |
|
164 |
state. (for example, see the systemBrowsers menus being different when |
|
165 |
things are selected ...) |
|
166 |
||
38 | 167 |
It is also possible, to add check-mark entries, with an entry string |
168 |
starting with the special sequence '\c' (for check-mark). The value |
|
169 |
passed will be the truth-state of the check-mark. |
|
170 |
||
284 | 171 |
|m v| |
38 | 172 |
|
284 | 173 |
v := View new. |
174 |
m := PopUpMenu |
|
175 |
labels:#('\c foo' |
|
176 |
'\c bar') |
|
177 |
selectors:#(#value: #value:) |
|
178 |
receiver:[:v | Transcript show:'arg: '; showCr:v]. |
|
179 |
v middleButtonMenu:m. |
|
180 |
v open |
|
38 | 181 |
|
404 | 182 |
The style of the checkmark can be: check (\c), box (\b) or thumbs (\t): |
183 |
||
184 |
|m v| |
|
185 |
||
186 |
v := View new. |
|
187 |
m := PopUpMenu |
|
188 |
labels:#('\c foo' |
|
189 |
'\b bar' |
|
190 |
'\t baz') |
|
191 |
selectors:#(#value: #value: #value:) |
|
192 |
receiver:[:v | Transcript show:'arg: '; showCr:v]. |
|
193 |
v middleButtonMenu:m. |
|
194 |
v open |
|
195 |
||
406 | 196 |
or at the end (looks better with variable fonts): |
197 |
||
198 |
|m v| |
|
199 |
||
200 |
v := View new. |
|
201 |
m := PopUpMenu |
|
202 |
labels:#('foo \c' |
|
203 |
'bar \b' |
|
204 |
'baz \t') |
|
205 |
selectors:#(#value: #value: #value:) |
|
206 |
receiver:[:v | Transcript show:'arg: '; showCr:v]. |
|
207 |
v middleButtonMenu:m. |
|
208 |
v open |
|
209 |
||
38 | 210 |
Finally, you can wrap other views into a popup menu (for example, |
211 |
to implement menus with icons or other components). |
|
212 |
The view should respond to some messages sent from here (for |
|
213 |
example: #hideSubmenus, #deselectWithoutRedraw and others). |
|
214 |
Currently there is only one class in the system, which can be used |
|
215 |
this way (PatternMenu in the DrawTool demo): |
|
216 |
||
284 | 217 |
|v p| |
38 | 218 |
|
284 | 219 |
v := View new. |
220 |
p := PatternMenu new. |
|
221 |
p patterns:(Array with:Color red |
|
222 |
with:Color green |
|
223 |
with:Color blue). |
|
224 |
v middleButtonMenu:(PopUpMenu forMenu:p). |
|
225 |
v open |
|
38 | 226 |
|
227 |
or try: |
|
228 |
||
284 | 229 |
|v p| |
38 | 230 |
|
284 | 231 |
v := View new. |
232 |
p := PatternMenu new. |
|
233 |
p patterns:(Array with:Color red |
|
234 |
with:Color green |
|
235 |
with:Color blue). |
|
236 |
p selectors:#value:. |
|
237 |
p receiver:[:val | v viewBackground:val. v clear]. |
|
238 |
p args:(Array with:Color red |
|
239 |
with:Color green |
|
240 |
with:Color blue). |
|
241 |
v middleButtonMenu:(PopUpMenu forMenu:p). |
|
242 |
v open |
|
38 | 243 |
|
244 |
||
245 |
ST-80 style: |
|
246 |
||
247 |
The above menus all did some message send on selection; it is |
|
248 |
also possible, to use Smalltalk-80 style menus (which return some value |
|
249 |
from their startup method): |
|
250 |
||
284 | 251 |
|m selection| |
38 | 252 |
|
284 | 253 |
m := PopUpMenu |
254 |
labels:#('one' 'two' 'three'). |
|
255 |
selection := m startUp. |
|
256 |
Transcript show:'the selection was: '; showCr:selection |
|
38 | 257 |
|
258 |
startUp will return the entries index, or 0 if there was no selection. |
|
259 |
You can also specify an array of values to be returned instead of the |
|
260 |
index: |
|
261 |
||
284 | 262 |
|m selection| |
38 | 263 |
|
284 | 264 |
m := PopUpMenu |
265 |
labels:#('one' 'two' 'three') |
|
266 |
values:#(10 20 30). |
|
267 |
selection := m startUp. |
|
268 |
Transcript show:'the value was: '; showCr:selection |
|
38 | 269 |
|
270 |
In ST/X style menus, separating lines between entries are created |
|
271 |
by a '-'-string as its label text (and corresponding nil-entries in the |
|
272 |
selectors- and args-arrays). |
|
273 |
In ST-80, you have to pass the indices of the lines in an extra array: |
|
274 |
||
284 | 275 |
|m selection| |
38 | 276 |
|
284 | 277 |
m := PopUpMenu |
278 |
labels:#('one' 'two' 'three' 'four' 'five') |
|
279 |
lines:#(2 4). |
|
280 |
selection := m startUp. |
|
281 |
Transcript show:'the value was: '; showCr:selection |
|
38 | 282 |
|
283 |
or: |
|
284 | 284 |
|m selection| |
38 | 285 |
|
284 | 286 |
m := PopUpMenu |
287 |
labels:#('one' 'two' 'three') |
|
288 |
lines:#(2) |
|
289 |
values:#(10 20 30). |
|
290 |
selection := m startUp. |
|
291 |
Transcript show:'the value was: '; showCr:selection |
|
38 | 292 |
|
293 |
Use whichever interface you prefer. |
|
294 |
" |
|
119 | 295 |
! ! |
296 |
||
297 |
!PopUpMenu class methodsFor:'instance creation'! |
|
38 | 298 |
|
299 |
forMenu:aMenuView |
|
300 |
"this wraps an already existing menu - allowing to put any |
|
301 |
view (not just MenuViews) into popups (for example, menus |
|
302 |
with icons, or other components). |
|
303 |
Currently, there is only one example of different menus in |
|
304 |
the system (PatternMenu in the DrawTool) which could be used |
|
305 |
this way. |
|
306 |
The view should respond to some of the menuView messages |
|
307 |
(such as hideSubmenu, deselectWithoutRedraw etc.)" |
|
308 |
||
309 |
|newMenu| |
|
310 |
||
311 |
newMenu := self onSameDeviceAs:aMenuView. |
|
312 |
newMenu addSubView:aMenuView. |
|
313 |
newMenu menu:aMenuView. |
|
314 |
^ newMenu |
|
315 |
! |
|
316 |
||
202 | 317 |
labels:labels selector:aSelector args:args receiver:anObject |
318 |
"create and return a popup menu with labels as entries. |
|
319 |
Each item will send aSelector with a corresponding argument from the |
|
320 |
args array to anObject. The menu is created on the default DIsplay" |
|
321 |
||
322 |
" |
|
323 |
OBSOLETE protocol: #labels:selectors:... knows how to handle single-symbol selectors-arg |
|
324 |
" |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
325 |
^ self labels:labels selectors:aSelector accelerators:nil args:args receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
326 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
327 |
"Modified: 28.2.1996 / 19:01:12 / cg" |
202 | 328 |
! |
329 |
||
330 |
labels:labels selector:aSelector args:args receiver:anObject for:aView |
|
331 |
"create and return a popup menu with labels as entries. |
|
332 |
Each item will send aSelector with a corresponding argument from the |
|
333 |
args array to anObject. The menu is created on the same physical device |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
334 |
as aView (which is only of interest in multi-Display applications; |
202 | 335 |
typical applications can use the sibbling message without the for: argument)." |
336 |
||
337 |
" |
|
338 |
OBSOLETE protocol: #labels:selectors:... knows how to handle single-symbol selectors-arg |
|
339 |
" |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
340 |
^ self labels:labels selectors:aSelector accelerators:nil args:args receiver:anObject for:aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
341 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
342 |
"Modified: 28.2.1996 / 19:01:29 / cg" |
202 | 343 |
! |
344 |
||
345 |
labels:labels selectors:selectors |
|
346 |
"create and return a menu with label-items and selectors. The receiver |
|
347 |
will either be defined later, or not used at all (if opened via startUp)" |
|
348 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
349 |
^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:nil for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
350 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
351 |
"Modified: 28.2.1996 / 19:01:35 / cg" |
202 | 352 |
! |
353 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
354 |
labels:labels selectors:selectors accelerators:shorties |
202 | 355 |
"create and return a menu with label-items and selectors. The receiver |
356 |
will either be defined later, or not used at all (if opened via startUp)" |
|
357 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
358 |
^ self labels:labels selectors:selectors accelerators:shorties args:nil receiver:nil for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
359 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
360 |
"Created: 28.2.1996 / 18:58:52 / cg" |
202 | 361 |
! |
362 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
363 |
labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject |
202 | 364 |
"create and return a popup menu with labels as entries. |
365 |
Each item will send a corresponding selector:argument from the selectors- |
|
366 |
and args array to anObject. The menu is created on the default Display" |
|
367 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
368 |
^ self labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
369 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
370 |
"Created: 28.2.1996 / 18:59:03 / cg" |
202 | 371 |
! |
372 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
373 |
labels:labels selectors:selectors accelerators:shorties args:args receiver:anObject for:aView |
63 | 374 |
"create and return a popup menu with labels as entries. |
375 |
Each item will send a corresponding selector:argument from the selectors- |
|
376 |
and args array to anObject. The menu is created on the same physical device |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
377 |
as aView (which is only of interest in multi-Display applications; |
63 | 378 |
typical applications can use the sibbling message without the for: argument)." |
379 |
||
38 | 380 |
|newMenu| |
381 |
||
382 |
newMenu := self onSameDeviceAs:aView. |
|
383 |
newMenu menu:(MenuView |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
384 |
labels:labels |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
385 |
selectors:selectors |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
386 |
accelerators:shorties |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
387 |
args:args |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
388 |
receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
389 |
in:newMenu). |
38 | 390 |
^ newMenu |
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
391 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
392 |
"Created: 28.2.1996 / 18:59:25 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
393 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
394 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
395 |
labels:labels selectors:selectors accelerators:shorties receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
396 |
"create and return a popup menu with labels as entries. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
397 |
Each item will send a message with a selector from the corresponding |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
398 |
selectors-array. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
399 |
The menu is created on the default Display." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
400 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
401 |
^ self labels:labels selectors:selectors accelerators:shorties args:nil receiver:anObject for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
402 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
403 |
"Created: 28.2.1996 / 19:00:49 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
404 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
405 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
406 |
labels:labels selectors:selectors args:argArray |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
407 |
"create and return a menu with label-items and selectors. The receiver |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
408 |
will either be defined later, or not used at all (if opened via startUp)" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
409 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
410 |
^ self labels:labels selectors:selectors accelerators:nil args:argArray receiver:nil for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
411 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
412 |
"Modified: 28.2.1996 / 19:01:45 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
413 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
414 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
415 |
labels:labels selectors:selectors args:args receiver:anObject |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
416 |
"create and return a popup menu with labels as entries. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
417 |
Each item will send a corresponding selector:argument from the selectors- |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
418 |
and args array to anObject. The menu is created on the default Display" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
419 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
420 |
^ self labels:labels selectors:selectors accelerators:nil args:args receiver:anObject for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
421 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
422 |
"Modified: 28.2.1996 / 19:01:49 / cg" |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
423 |
! |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
424 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
425 |
labels:labels selectors:selectors args:args receiver:anObject for:aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
426 |
"create and return a popup menu with labels as entries. |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
427 |
Each item will send a corresponding selector:argument from the selectors- |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
428 |
and args array to anObject. The menu is created on the same physical device |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
429 |
as aView (which is only of interest in multi-Display applications; |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
430 |
typical applications can use the sibbling message without the for: argument)." |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
431 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
432 |
^ self labels:labels selectors:selectors accelerators:nil args:args receiver:anObject for:aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
433 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
434 |
"Modified: 28.2.1996 / 19:03:58 / cg" |
38 | 435 |
! |
436 |
||
119 | 437 |
labels:labels selectors:selectors receiver:anObject |
438 |
"create and return a popup menu with labels as entries. |
|
439 |
Each item will send a message with a selector from the corresponding |
|
440 |
selectors-array. |
|
441 |
The menu is created on the default Display." |
|
442 |
||
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
443 |
^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:anObject for:nil |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
444 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
445 |
"Modified: 28.2.1996 / 19:02:07 / cg" |
63 | 446 |
! |
447 |
||
202 | 448 |
labels:labels selectors:selectors receiver:anObject for:aView |
449 |
"create and return a popup menu with labels as entries. |
|
450 |
Each item will send a corresponding selector from the selectors-array |
|
451 |
to anObject. The menu is created on the same physical device |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
452 |
as aView (which is only of interest in multi-Display applications; |
202 | 453 |
typical applications can use the sibbling message without the for: argument)." |
63 | 454 |
|
426
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
455 |
^ self labels:labels selectors:selectors accelerators:nil args:nil receiver:anObject for:aView |
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
456 |
|
bf35bf40ab11
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
457 |
"Modified: 28.2.1996 / 19:02:10 / cg" |
0 | 458 |
! ! |
459 |
||
460 |
!PopUpMenu class methodsFor:'ST-80 instance creation'! |
|
461 |
||
202 | 462 |
labelArray:labels lines:lines values:values |
463 |
"ST80R4 compatibility" |
|
119 | 464 |
|
202 | 465 |
^ self labels:labels lines:lines values:values |
0 | 466 |
! |
467 |
||
119 | 468 |
labelArray:labels values:values |
469 |
"ST80R4 compatibility" |
|
470 |
||
471 |
^ self labels:labels lines:nil values:values |
|
472 |
! |
|
473 |
||
202 | 474 |
labelList:labels |
475 |
"ST80R4 compatibility: |
|
476 |
given a list consisting of group label entries (to be separated by |
|
477 |
lines), convert into standard form (using '-' for lines. |
|
478 |
" |
|
479 |
||
480 |
^ self labelList:labels values:nil |
|
119 | 481 |
|
202 | 482 |
" |
483 |
(PopUpMenu labels:#('1' '2' '3')) showAtPointer |
|
484 |
(PopUpMenu labelList:#(('1') ('2' '3'))) showAtPointer |
|
485 |
(PopUpMenu labelList:#(('1') ('2') ('3'))) showAtPointer |
|
486 |
" |
|
487 |
! |
|
488 |
||
489 |
labelList:labels lines:lines values:values |
|
490 |
"mhmh what is that ?" |
|
491 |
||
492 |
^ (self new) labels:labels lines:lines values:values |
|
119 | 493 |
! |
494 |
||
0 | 495 |
labelList:labels values:values |
119 | 496 |
"ST80R4 compatibility: |
497 |
given a list consisting of group label entries (to be separated by |
|
498 |
lines), convert into standard form (using '-' for lines. |
|
499 |
" |
|
500 |
||
501 |
|newLabels newValues lS vS first| |
|
502 |
||
503 |
newLabels := OrderedCollection new. |
|
504 |
newValues := OrderedCollection new. |
|
505 |
lS := ReadStream on:labels. |
|
506 |
values notNil ifTrue:[vS := ReadStream on:values]. |
|
507 |
first := true. |
|
508 |
[lS atEnd] whileFalse:[ |
|
509 |
|entry| |
|
510 |
||
511 |
entry := lS next. |
|
512 |
entry isCollection ifTrue:[ |
|
513 |
first ifFalse:[ |
|
514 |
newLabels add:'-'. |
|
515 |
values notNil ifTrue:[newValues add:nil] |
|
516 |
]. |
|
517 |
newLabels addAll:entry. |
|
518 |
values notNil ifTrue:[newValues addAll:(vS next:entry size)] |
|
519 |
] ifFalse:[ |
|
520 |
newLabels add:entry. |
|
521 |
values notNil ifTrue:[newValues add:(vS next)] |
|
522 |
]. |
|
523 |
first := false. |
|
524 |
]. |
|
525 |
values isNil ifTrue:[ |
|
526 |
^ self labels:newLabels |
|
527 |
]. |
|
528 |
^ self labels:newLabels values:newValues |
|
529 |
||
530 |
" |
|
531 |
(PopUpMenu labels:#('1' '2' '3') values:#(1 2 3)) showAtPointer |
|
532 |
(PopUpMenu labelList:#(('1') ('2' '3')) values:#(1 2 3)) showAtPointer |
|
533 |
(PopUpMenu labelList:#(('1') ('2') ('3')) values:#(1 2 3)) showAtPointer |
|
534 |
" |
|
535 |
! |
|
536 |
||
202 | 537 |
labels:labels |
538 |
"ST80R2 compatibility" |
|
59 | 539 |
|
202 | 540 |
^ self labels:labels lines:nil values:nil |
0 | 541 |
! |
542 |
||
202 | 543 |
labels:labels lines:lines |
544 |
"ST80R2 compatibility" |
|
0 | 545 |
|
202 | 546 |
^ self labels:labels lines:lines values:nil |
77 | 547 |
! |
548 |
||
202 | 549 |
labels:labels lines:lines values:values |
550 |
"ST80R2 compatibility" |
|
127 | 551 |
|
202 | 552 |
^ (self new) labels:labels lines:lines values:values |
77 | 553 |
! |
554 |
||
202 | 555 |
labels:labels values:values |
556 |
"ST80R2 compatibility" |
|
59 | 557 |
|
202 | 558 |
^ self labels:labels lines:nil values:values |
127 | 559 |
! ! |
560 |
||
202 | 561 |
!PopUpMenu class methodsFor:'defaults'! |
0 | 562 |
|
202 | 563 |
updateStyleCache |
564 |
DefaultHideOnRelease := StyleSheet at:#popupHideOnRelease default:true. |
|
0 | 565 |
! ! |
566 |
||
567 |
!PopUpMenu methodsFor:'ST-80 activation'! |
|
568 |
||
569 |
startUp |
|
38 | 570 |
"start the menu modal - return the selected value, |
571 |
or - if no values where specified - return the index. |
|
0 | 572 |
If nothing was selected, return 0. |
38 | 573 |
Modal - i.e. stay in the menu until finished. |
574 |
This is the ST-80 way of launching a menu." |
|
0 | 575 |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
576 |
^ self startUpAt:nil |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
577 |
|
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
578 |
" |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
579 |
Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
580 |
Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz') |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
581 |
values:#(foo bar baz)) startUp |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
582 |
" |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
583 |
|
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
584 |
"Modified: 10.1.1996 / 20:16:40 / cg" |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
585 |
! |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
586 |
|
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
587 |
startUpAt:aPoint |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
588 |
"start the menu modal - return the selected value, |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
589 |
or - if no values where specified - return the index. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
590 |
If nothing was selected, return 0. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
591 |
Modal - i.e. stay in the menu until finished. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
592 |
This is the ST-80 way of launching a menu." |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
593 |
|
96 | 594 |
|return rec sel0 sel1 arg| |
63 | 595 |
|
119 | 596 |
return := 0. |
597 |
||
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
598 |
"/ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
599 |
"/ arrange for the menu to evaluate this action, |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
600 |
"/ instead of directly sending any messages to the menuReceiver. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
601 |
"/ (which used to be the ST/X way, menus worked). |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
602 |
"/ This works better with menuPerformers - which were not |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
603 |
"/ supported when ST/X menus were originally written. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
604 |
"/ The old ST/X mechanism may vanish. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
605 |
"/ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
606 |
|
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
607 |
menuView action:[:menuView :selected | |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
608 |
|actionIndex value sel retVal |
575
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
609 |
args selectors checkFlags check| |
38 | 610 |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
611 |
retVal := 0. |
95 | 612 |
|
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
613 |
args := menuView args. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
614 |
selectors := menuView selectors. |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
615 |
checkFlags := menuView checkFlags. |
119 | 616 |
|
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
617 |
args isNil ifTrue:[ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
618 |
selectors notNil ifTrue:[ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
619 |
sel0 := selectors at:selected. |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
620 |
]. |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
621 |
] ifFalse:[ |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
622 |
actionIndex := args at:selected. |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
623 |
actionIndex notNil ifTrue:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
624 |
actionValues isNil ifTrue:[ |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
625 |
selectors notNil ifTrue:[ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
626 |
"/ mhmh an ST/X menu started the ST-80 way |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
627 |
|
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
628 |
sel1 := selectors at:selected. |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
629 |
arg := actionIndex. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
630 |
] ifFalse:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
631 |
retVal := actionIndex |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
632 |
] |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
633 |
] ifFalse:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
634 |
retVal := actionValues at:actionIndex. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
635 |
(retVal isKindOf:PopUpMenu) ifTrue:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
636 |
retVal := retVal startUp |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
637 |
] |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
638 |
] |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
639 |
] ifFalse:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
640 |
"/ mhmh an ST/X menu started the ST-80 way |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
641 |
|
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
642 |
selectors notNil ifTrue:[ |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
643 |
sel0 := selectors at:selected. |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
644 |
]. |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
645 |
] |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
646 |
]. |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
647 |
|
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
648 |
checkFlags notNil ifTrue:[ |
575
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
649 |
check := checkFlags at:selected. |
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
650 |
check notNil ifTrue:[ |
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
651 |
arg := check. |
568
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
652 |
sel1 := sel0. |
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
653 |
sel0 := nil. |
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
654 |
] |
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
655 |
]. |
ba7d2bc390ae
oops - checkFlags passed wrong arg
Claus Gittinger <cg@exept.de>
parents:
545
diff
changeset
|
656 |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
657 |
return := retVal |
0 | 658 |
]. |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
659 |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
660 |
aPoint isNil ifTrue:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
661 |
self showAtPointer |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
662 |
] ifFalse:[ |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
663 |
self showAt:aPoint. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
664 |
]. |
96 | 665 |
|
666 |
"/ |
|
667 |
"/ mhmh an ST/X menu started the ST-80 way |
|
668 |
"/ |
|
669 |
(sel0 notNil or:[sel1 notNil]) ifTrue:[ |
|
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
670 |
rec := menuView receiver. |
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
671 |
sel0 notNil ifTrue:[ |
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
672 |
^ sel0 |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
673 |
]. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
674 |
^ Array with:sel1 with:arg. |
95 | 675 |
]. |
63 | 676 |
^ return |
38 | 677 |
|
678 |
" |
|
63 | 679 |
Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp |
38 | 680 |
Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz') |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
681 |
values:#(foo bar baz)) startUp |
38 | 682 |
" |
281
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
683 |
|
0f41c95fa722
added method to open menu at a particular position
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
684 |
"Created: 10.1.1996 / 20:11:42 / cg" |
575
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
685 |
"Modified: 23.4.1996 / 18:58:26 / cg" |
110 | 686 |
! |
687 |
||
688 |
startUpWithHeading:aString |
|
689 |
"start the menu modal - return the selected value, |
|
690 |
or - if no values where specified - return the index. |
|
691 |
If nothing was selected, return 0. |
|
692 |
Modal - i.e. stay in the menu until finished. |
|
693 |
This is the ST-80 way of launching a menu." |
|
694 |
||
695 |
defaultHideOnRelease := false. |
|
696 |
menuView labels notNil ifTrue:[ |
|
697 |
menuView labels:(Array with:aString with:'=') , menuView labels. |
|
698 |
]. |
|
699 |
menuView selectors notNil ifTrue:[ |
|
700 |
menuView selectors:(Array with:nil with:nil) , menuView selectors. |
|
701 |
]. |
|
702 |
"/ menuView disable:1; disable:2. |
|
703 |
||
704 |
^ self startUp. |
|
705 |
||
706 |
" |
|
707 |
(PopUpMenu |
|
708 |
labels:#('foo' 'bar')) |
|
709 |
startUp |
|
710 |
" |
|
711 |
" |
|
712 |
(PopUpMenu |
|
713 |
labels:#('foo' 'bar')) |
|
714 |
startUpWithHeading:'hello' |
|
715 |
" |
|
0 | 716 |
! ! |
717 |
||
202 | 718 |
!PopUpMenu methodsFor:'accessing-behavior'! |
719 |
||
720 |
hideOnLeave:aBoolean |
|
721 |
"set/clear the hideOnLeave attribute, which controls |
|
722 |
if the menu should be hidden when the pointer leaves |
|
723 |
the view (used with multiple-menus)" |
|
724 |
||
725 |
hideOnLeave := aBoolean |
|
726 |
! |
|
727 |
||
728 |
hideOnRelease:aBoolean |
|
729 |
"set/clear the hideOnRelease attribute, which controls |
|
730 |
if the menu should be hidden when the button is released" |
|
731 |
||
335
81c8965c4437
hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents:
284
diff
changeset
|
732 |
defaultHideOnRelease := aBoolean. |
81c8965c4437
hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents:
284
diff
changeset
|
733 |
menuView hideOnRelease:aBoolean |
81c8965c4437
hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents:
284
diff
changeset
|
734 |
|
81c8965c4437
hideOnRelease fixes for COmboBox
Claus Gittinger <cg@exept.de>
parents:
284
diff
changeset
|
735 |
"Modified: 9.2.1996 / 02:06:15 / cg" |
202 | 736 |
! ! |
737 |
||
738 |
!PopUpMenu methodsFor:'accessing-items'! |
|
739 |
||
740 |
indexOf:indexOrName |
|
741 |
"return the index of a submenu - or 0 if there is none" |
|
742 |
||
743 |
^ menuView indexOf:indexOrName |
|
744 |
! |
|
745 |
||
746 |
labels |
|
747 |
"return the list of labels" |
|
748 |
||
749 |
actionLabels notNil ifTrue:[ |
|
750 |
^ actionLabels asStringCollection |
|
751 |
]. |
|
752 |
^ menuView list |
|
753 |
! |
|
754 |
||
755 |
labels:labelString lines:lineArray values:valueArray |
|
756 |
"define the menu the ST-80 way (with labels and lines defined separately)" |
|
757 |
||
758 |
|labelArray argArray convertedLabels |
|
759 |
offs dstOffs linePos| |
|
760 |
||
761 |
actionLabels := labelString. |
|
762 |
actionLines := lineArray. |
|
763 |
actionValues := valueArray. |
|
764 |
||
765 |
labelArray := labelString asStringCollection. |
|
766 |
||
767 |
convertedLabels := Array new:(labelArray size + lineArray size). |
|
768 |
argArray := Array new:(labelArray size + lineArray size). |
|
769 |
||
770 |
offs := 1. |
|
771 |
dstOffs := 1. |
|
772 |
1 to:lineArray size do:[:lineIndex | |
|
773 |
linePos := lineArray at:lineIndex. |
|
774 |
[offs <= linePos] whileTrue:[ |
|
775 |
convertedLabels at:dstOffs put:(labelArray at:offs). |
|
776 |
argArray at:dstOffs put:offs. |
|
777 |
offs := offs + 1. |
|
778 |
dstOffs := dstOffs + 1 |
|
779 |
]. |
|
780 |
convertedLabels at:dstOffs put:'-'. |
|
781 |
argArray at:dstOffs put:nil. |
|
782 |
dstOffs := dstOffs + 1 |
|
783 |
]. |
|
784 |
[offs <= labelArray size] whileTrue:[ |
|
785 |
convertedLabels at:dstOffs put:(labelArray at:offs). |
|
786 |
argArray at:dstOffs put:offs. |
|
787 |
offs := offs + 1. |
|
788 |
dstOffs := dstOffs + 1 |
|
789 |
]. |
|
790 |
self menu:(MenuView |
|
791 |
labels:convertedLabels |
|
792 |
selectors:nil |
|
793 |
args:argArray |
|
794 |
receiver:nil |
|
795 |
in:self) |
|
796 |
! |
|
797 |
||
798 |
lines |
|
799 |
"st-80 compatibility" |
|
800 |
||
801 |
^ actionLines |
|
802 |
! |
|
803 |
||
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
804 |
menuAt:indexOrName |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
805 |
"return the submenu for entry indexOrName." |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
806 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
807 |
^ self subMenuAt:indexOrName |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
808 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
809 |
"Created: 24.3.1996 / 17:11:05 / cg" |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
810 |
! |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
811 |
|
202 | 812 |
numberOfItems |
813 |
"return the number of items in the menu" |
|
814 |
||
815 |
actionLabels notNil ifTrue:[ |
|
816 |
^ actionLabels asStringCollection size |
|
817 |
]. |
|
818 |
^ menuView list size |
|
819 |
! |
|
820 |
||
821 |
remove:indexOrName |
|
822 |
"remove a menu entry" |
|
823 |
||
824 |
menuView remove:indexOrName |
|
825 |
! |
|
826 |
||
518
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
827 |
subMenuAt:indexOrName |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
828 |
"return the submenu for entry indexOrName" |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
829 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
830 |
^ menuView subMenuAt:indexOrName |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
831 |
|
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
832 |
"Created: 24.3.1996 / 17:09:15 / cg" |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
833 |
! |
731c905a6d89
unified #menuAt/#subMenuAt method names
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
834 |
|
202 | 835 |
subMenuAt:indexOrName put:aMenu |
836 |
"define a submenu to be shown for entry indexOrName" |
|
837 |
||
838 |
" |
|
839 |
aMenu hideOnLeave:true. |
|
840 |
" |
|
841 |
menuView subMenuAt:indexOrName put:aMenu. |
|
842 |
"tell the submenu to notify me when action is performed" |
|
843 |
aMenu superMenu:self. |
|
844 |
||
845 |
" |
|
846 |
|v m someObject| |
|
847 |
||
848 |
v := View new. |
|
849 |
m := PopUpMenu labels:#('1' '2' '3') |
|
850 |
selectors:#(one two nil) |
|
851 |
receiver:someObject |
|
852 |
for:nil. |
|
853 |
m subMenuAt:3 put:(PopUpMenu |
|
854 |
labels:#('a' 'b' 'c') |
|
855 |
selectors:#(a b c) |
|
856 |
receiver:someObject |
|
857 |
for:nil). |
|
858 |
v middleButtonMenu:m. |
|
859 |
v realize |
|
860 |
" |
|
861 |
! |
|
862 |
||
863 |
values |
|
864 |
"st-80 compatibility" |
|
865 |
||
866 |
^ actionValues |
|
867 |
! |
|
868 |
||
869 |
values:aValueArray |
|
870 |
"st-80 compatibility" |
|
871 |
||
872 |
actionValues := aValueArray |
|
873 |
! ! |
|
874 |
||
875 |
!PopUpMenu methodsFor:'accessing-look'! |
|
876 |
||
877 |
font:aFont |
|
878 |
menuView font:aFont |
|
879 |
! |
|
880 |
||
881 |
viewBackground:aColor |
|
882 |
"this is a kludge and will vanish ..." |
|
883 |
||
884 |
super viewBackground:aColor. |
|
885 |
menuView viewBackground:aColor |
|
886 |
! ! |
|
887 |
||
888 |
!PopUpMenu methodsFor:'accessing-mvc'! |
|
889 |
||
890 |
changeMessage |
|
891 |
"forward from my menu" |
|
892 |
||
893 |
^ menuView changeMessage |
|
894 |
! |
|
895 |
||
896 |
changeMessage:aSymbol |
|
897 |
"forward to my menu" |
|
898 |
||
899 |
menuView changeMessage:aSymbol |
|
900 |
! |
|
901 |
||
902 |
model |
|
903 |
^ menuView model |
|
904 |
! |
|
905 |
||
906 |
model:aModel |
|
907 |
menuView model:aModel |
|
908 |
! ! |
|
909 |
||
910 |
!PopUpMenu methodsFor:'deactivation'! |
|
911 |
||
912 |
hide |
|
913 |
"hide the menu - if there are any pop-up-submenus, hide them also" |
|
914 |
||
915 |
menuView hideSubmenu. |
|
916 |
windowGroup notNil ifTrue:[ |
|
917 |
windowGroup removeView:menuView. |
|
918 |
]. |
|
919 |
super hide. |
|
920 |
menuView superMenu notNil ifTrue:[ |
|
921 |
menuView superMenu regainControl |
|
922 |
]. |
|
923 |
! ! |
|
924 |
||
70 | 925 |
!PopUpMenu methodsFor:'event handling'! |
0 | 926 |
|
161 | 927 |
buttonMotion:state x:x y:y |
70 | 928 |
|p superMenu| |
7 | 929 |
|
161 | 930 |
state == 0 ifTrue:[^ self]. |
931 |
||
38 | 932 |
((x >= 0) and:[x < width]) ifTrue:[ |
59 | 933 |
((y >= 0) and:[y < height]) ifTrue:[ |
105 | 934 |
hideOnRelease := true. |
161 | 935 |
menuView buttonMotion:state x:x y:y. |
59 | 936 |
^ self |
937 |
] |
|
0 | 938 |
]. |
7 | 939 |
|
940 |
"outside of myself" |
|
70 | 941 |
superMenu := menuView superMenu. |
942 |
superMenu notNil ifTrue:[ |
|
59 | 943 |
p := device translatePoint:(x @ y) |
944 |
from:drawableId |
|
945 |
to:(menuView superMenu id). |
|
161 | 946 |
superMenu buttonMotion:state x:p x y:p y |
7 | 947 |
]. |
948 |
||
949 |
menuView subMenuShown isNil ifTrue:[ |
|
161 | 950 |
menuView pointerLeave:state. |
7 | 951 |
]. |
952 |
||
0 | 953 |
hideOnLeave ifTrue:[ |
59 | 954 |
self hide |
38 | 955 |
]. |
0 | 956 |
! |
957 |
||
105 | 958 |
buttonPress:button x:x y:y |
497 | 959 |
hideOnRelease := true. |
960 |
((x >= 0) and:[x < width]) ifTrue:[ |
|
961 |
((y >= 0) and:[y < height]) ifTrue:[ |
|
962 |
menuView buttonPress:button x:x y:y. |
|
963 |
^ self |
|
964 |
] |
|
105 | 965 |
]. |
497 | 966 |
|
967 |
"Modified: 8.3.1996 / 14:03:34 / cg" |
|
105 | 968 |
! |
969 |
||
0 | 970 |
buttonRelease:button x:x y:y |
497 | 971 |
|now| |
972 |
||
973 |
realized ifFalse:[^ self]. |
|
974 |
||
975 |
"/ |
|
976 |
"/ detect short click - stay open if this is one |
|
977 |
"/ |
|
978 |
(OperatingSystem |
|
979 |
millisecondTimeDeltaBetween:(Time millisecondClockValue) |
|
980 |
and:mapTime) > 200 ifFalse:[ |
|
981 |
hideOnRelease := false |
|
982 |
]. |
|
983 |
||
105 | 984 |
hideOnRelease ifFalse:[ |
425 | 985 |
^ self |
105 | 986 |
]. |
987 |
||
497 | 988 |
(x < 0 |
989 |
or:[x >= width |
|
990 |
or:[y < 0 |
|
991 |
or:[y >= height]]]) ifTrue:[ |
|
992 |
"/ |
|
993 |
"/ released outside of mySelf |
|
994 |
"/ |
|
995 |
menuView superMenu notNil ifTrue:[ |
|
996 |
menuView superMenu hideSubmenu |
|
997 |
] ifFalse:[ |
|
998 |
self hide |
|
999 |
]. |
|
1000 |
^ self |
|
1001 |
]. |
|
1002 |
||
1003 |
||
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
1004 |
"/ menuView superMenu notNil ifTrue:[ |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
1005 |
"/ menuView superMenu submenuTriggered |
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
1006 |
"/ ]. |
497 | 1007 |
|
7 | 1008 |
menuView buttonRelease:button x:x y:y. |
425 | 1009 |
|
497 | 1010 |
"Modified: 8.3.1996 / 14:17:18 / cg" |
112 | 1011 |
! |
1012 |
||
1013 |
keyPress:key x:x y:y |
|
491 | 1014 |
<resource: #keyboard (#Tab)> |
1015 |
||
465
b473edeab54e
can now be controlled by keyboard
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
1016 |
(x isNil or:[x == 0]) ifTrue:[ |
425 | 1017 |
"/ already redelegated |
1018 |
^ self |
|
1019 |
]. |
|
1020 |
||
348
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1021 |
key == #Tab ifTrue:[ |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1022 |
self hide. |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1023 |
super keyPress:key x:x y:y. |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1024 |
] ifFalse:[ |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1025 |
menuView keyPress:key x:x y:y. |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1026 |
]. |
2925bbd4f346
dont forward Tab to pulled views
Claus Gittinger <cg@exept.de>
parents:
342
diff
changeset
|
1027 |
|
491 | 1028 |
"Modified: 7.3.1996 / 13:17:54 / cg" |
202 | 1029 |
! |
1030 |
||
342
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1031 |
mapped |
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1032 |
super mapped. |
497 | 1033 |
|
1034 |
"/ |
|
1035 |
"/ check if a button is pressed when mapped; |
|
1036 |
"/ if not, change my hide-strategy |
|
1037 |
"/ |
|
1038 |
||
1039 |
"/ device buttonStates == 0 ifTrue:[ |
|
1040 |
"/ hideOnRelease := false |
|
1041 |
"/ ]. |
|
342
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1042 |
|
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1043 |
"Created: 9.2.1996 / 19:56:20 / cg" |
497 | 1044 |
"Modified: 8.3.1996 / 13:42:15 / cg" |
342
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1045 |
! |
ddbe4e8d6e9f
check if buttons are down at map-time; change release behavior, if no button is pressed then
Claus Gittinger <cg@exept.de>
parents:
335
diff
changeset
|
1046 |
|
202 | 1047 |
pointerEnter:state x:x y:y |
1048 |
"catch quick release of button" |
|
1049 |
||
1050 |
hideOnLeave ifTrue:[ |
|
1051 |
state == 0 ifTrue:[^ self hide]. |
|
1052 |
] |
|
1053 |
! |
|
1054 |
||
1055 |
pointerLeave:state |
|
1056 |
"/ menuView pointerLeave:state. |
|
1057 |
"/ hideOnLeave ifTrue:[ |
|
1058 |
"/ self hide |
|
1059 |
"/ ]. |
|
1060 |
"/ menuView superMenu notNil ifTrue:[ |
|
1061 |
"/ menuView superMenu regainControl |
|
1062 |
"/ ] |
|
0 | 1063 |
! ! |
202 | 1064 |
|
1065 |
!PopUpMenu methodsFor:'initialization'! |
|
1066 |
||
1067 |
initEvents |
|
1068 |
super initEvents. |
|
1069 |
self enableEnterLeaveEvents. |
|
495
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1070 |
"/ self enableMotionEvents. |
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1071 |
|
d993f23ea658
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
Claus Gittinger <cg@exept.de>
parents:
491
diff
changeset
|
1072 |
"Modified: 7.3.1996 / 14:17:42 / cg" |
202 | 1073 |
! |
1074 |
||
1075 |
initialize |
|
1076 |
super initialize. |
|
1077 |
||
1078 |
memorize := true. |
|
1079 |
hideOnLeave := false. |
|
1080 |
defaultHideOnRelease := DefaultHideOnRelease. |
|
1081 |
! ! |
|
1082 |
||
1083 |
!PopUpMenu methodsFor:'menuview messages'! |
|
1084 |
||
1085 |
doesNotUnderstand:aMessage |
|
1086 |
"forward all menu-view messages" |
|
1087 |
||
1088 |
(menuView respondsTo:(aMessage selector)) ifTrue:[ |
|
1089 |
^ aMessage sendTo:menuView |
|
1090 |
]. |
|
1091 |
^ super doesNotUnderstand:aMessage |
|
1092 |
! ! |
|
1093 |
||
1094 |
!PopUpMenu methodsFor:'private accessing'! |
|
1095 |
||
1096 |
menu:aMenu |
|
1097 |
"set the actual menu" |
|
1098 |
||
1099 |
menuView := aMenu. |
|
1100 |
menuView origin:(margin @ margin). |
|
1101 |
menuView borderWidth:0. |
|
1102 |
menuView masterView:self |
|
1103 |
! |
|
1104 |
||
1105 |
menuView |
|
1106 |
"return the actual menu" |
|
1107 |
||
1108 |
^ menuView |
|
1109 |
! |
|
1110 |
||
1111 |
superMenu:aMenu |
|
1112 |
"return the superMenu" |
|
1113 |
||
1114 |
menuView superMenu:aMenu |
|
1115 |
! ! |
|
1116 |
||
1117 |
!PopUpMenu methodsFor:'realization'! |
|
1118 |
||
1119 |
fixSize |
|
1120 |
"called right before the view is made visible. |
|
1121 |
adjust my size to the size of the actual menu" |
|
1122 |
||
1123 |
|extra newWidth newHeight| |
|
1124 |
||
1125 |
extra := margin * 2. |
|
1126 |
menuView resizeIfChanged. |
|
1127 |
newWidth := menuView width + extra. |
|
1128 |
newHeight := menuView height + extra. |
|
1129 |
((newWidth ~~ width) or:[newHeight ~~ height]) ifTrue:[ |
|
1130 |
self extent:(menuView width + extra) @ (menuView height + extra) |
|
1131 |
]. |
|
1132 |
super fixSize |
|
1133 |
! |
|
1134 |
||
1135 |
realize |
|
1136 |
menuView deselectWithoutRedraw. |
|
1137 |
super realize. |
|
1138 |
hideOnRelease := defaultHideOnRelease. |
|
1139 |
! ! |
|
1140 |
||
205 | 1141 |
!PopUpMenu class methodsFor:'documentation'! |
1142 |
||
1143 |
version |
|
575
fe3c389931f7
oops - arg was not passed if there are checkFlags
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
1144 |
^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.47 1996-04-23 16:59:15 cg Exp $' |
205 | 1145 |
! ! |