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