author | Claus Gittinger <cg@exept.de> |
Sat, 28 Jun 1997 14:06:53 +0200 | |
changeset 633 | 5d162347fac8 |
parent 632 | 844b1aaf3eeb |
child 634 | 1d88f55984a2 |
permissions | -rw-r--r-- |
59 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
14 |
EventListener subclass:#ActiveHelp |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
15 |
instanceVariableNames:'currentView currentHelpView currentFrame showProcess closeProcess |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
16 |
lastHelpText' |
216 | 17 |
classVariableNames:'DelayTime ShowTime TheOneAndOnlyHelpListener' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Help' |
|
59 | 20 |
! |
21 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
22 |
!ActiveHelp class methodsFor:'documentation'! |
59 | 23 |
|
138 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
59 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
98 | 41 |
The active help listener. |
42 |
The one and only instance of myself intercepts incoming mouse & keyboard |
|
43 |
events for the display device, being especially interested in view-enter/ |
|
100 | 44 |
leave enents. When such an event arrives, it asks the corresponding view |
98 | 45 |
or its model for a help message and display it via an ActiveHelpView. |
100 | 46 |
This query is repeated along the views superView chain, until any model or |
47 |
view returns a nonNil answer for the #helpTextFor:at or #helpTextFor |
|
48 |
message. |
|
49 |
||
98 | 50 |
All I need for automatic help is some model/view/applicationModel along |
51 |
the superview chain of the entered component, which responds to the |
|
52 |
#helpTextFor: message with a non-nil (string-) answer. |
|
53 |
I close down the help view after a while, if a key is pressed or the mouse |
|
54 |
moved to another view. |
|
100 | 55 |
|
56 |
Who should provide the helpText: |
|
57 |
||
221 | 58 |
the best place is the application object (an instance of ApplicationModel) |
59 |
or the topView, if its a derived class of StandardSystemView. |
|
60 |
This should know about its components and return the string |
|
61 |
when asked via #helpTextFor:aComponent. |
|
330
d7ce98930ad3
Rename Launcher-->OldLauncher, NewLauncher-->Launcher.
Stefan Vogel <sv@exept.de>
parents:
297
diff
changeset
|
62 |
See examples in FileBrowser, Launcher etc. |
100 | 63 |
|
64 |
Be aware, that for applicationModels, there must be a link from the |
|
65 |
topView to this applicationModel |
|
66 |
(set via: aTopView application:anApplicationModel) |
|
67 |
otherwise, the helpManager has no means of finding the application which |
|
68 |
corresponds to a view. |
|
69 |
||
70 |
Who should display the helpText: |
|
71 |
||
221 | 72 |
by default, the helpListener opens a little popup view, which displays the |
73 |
returned help message. However, a nice trick which can be used by applications |
|
74 |
is to create an infoLabel as a subview of the topFrame (a la windows) |
|
75 |
and display the text right in the #helpTextFor: method. To cheat the |
|
76 |
help listener, this method should then return nil, to keep it silent. |
|
77 |
||
78 |
||
79 |
[author:] |
|
80 |
Claus Gittinger |
|
81 |
||
233 | 82 |
[start with:] |
83 |
ActiveHelp start |
|
84 |
ActiveHelp stop |
|
85 |
||
221 | 86 |
[See also:] |
233 | 87 |
ActiveHelpView |
88 |
WindowGroup WindowEvent |
|
89 |
ApplicationModel StandardSystemView |
|
100 | 90 |
" |
91 |
! |
|
92 |
||
93 |
examples |
|
94 |
" |
|
233 | 95 |
(make certain that activeHelp is turned on ... |
96 |
... otherwise, you will see nothing) |
|
100 | 97 |
|
98 |
the following example uses a Plug as a model replacement. |
|
99 |
In concrete application, you would create a method to implement the helpText |
|
100 |
query message. |
|
227 | 101 |
[exBegin] |
102 |
|app top button1 button2| |
|
100 | 103 |
|
227 | 104 |
app := Plug new. |
105 |
app respondTo:#helpTextFor: |
|
106 |
with:[:view | |
|
107 |
view == button1 ifTrue:[ |
|
108 |
'this is button1' |
|
109 |
] ifFalse:[ |
|
110 |
view == button2 ifTrue:[ |
|
111 |
'some help for button2' |
|
112 |
] ifFalse:[ |
|
113 |
nil |
|
114 |
] |
|
115 |
] |
|
116 |
]. |
|
100 | 117 |
|
227 | 118 |
top := StandardSystemView new. |
119 |
top extent:300@100. |
|
120 |
button1 := Button label:'b1' in:top. |
|
121 |
button1 origin:0.0@0.0 corner:0.5@30. |
|
122 |
button2 := Button label:'b2' in:top. |
|
123 |
button2 origin:0.5@0.0 corner:1.0@30. |
|
124 |
top model:app. '<-- normally this would be: top application:app'. |
|
125 |
top open |
|
126 |
[exEnd] |
|
100 | 127 |
|
233 | 128 |
(make certain that activeHelp is turned on ... |
129 |
... otherwise, you will see nothing) |
|
130 |
||
227 | 131 |
alternatively, display of the helpMessage in a local, private view: |
132 |
[exBegin] |
|
133 |
|app top button1 button2 infoView| |
|
100 | 134 |
|
227 | 135 |
app := Plug new. |
136 |
app respondTo:#helpTextFor: |
|
137 |
with:[:view | infoView label:'info ...'. |
|
138 |
view == button1 ifTrue:[ |
|
139 |
infoView label:'this is button1' |
|
140 |
]. |
|
141 |
view == button2 ifTrue:[ |
|
142 |
infoView label:'some help for button2' |
|
143 |
]. |
|
144 |
nil |
|
145 |
]. |
|
100 | 146 |
|
227 | 147 |
top := StandardSystemView new. |
148 |
top extent:300@100. |
|
149 |
button1 := Button label:'b1' in:top. |
|
150 |
button1 origin:0.0@0.0 corner:0.5@30. |
|
151 |
button2 := Button label:'b2' in:top. |
|
152 |
button2 origin:0.5@0.0 corner:1.0@30. |
|
153 |
infoView := Label label:'info ...' in:top. |
|
154 |
infoView level:-1; origin:0.0@1.0 corner:1.0@1.0. |
|
155 |
infoView topInset:(infoView preferredExtent y negated - 3); |
|
156 |
leftInset:3; |
|
157 |
rightInset:3; |
|
158 |
bottomInset:3; |
|
159 |
adjust:#left. |
|
160 |
top model:app. '<-- normally this would be: top application:app'. |
|
161 |
top open |
|
162 |
[exEnd] |
|
59 | 163 |
" |
164 |
! ! |
|
165 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
166 |
!ActiveHelp class methodsFor:'initialization'! |
59 | 167 |
|
168 |
initialize |
|
233 | 169 |
"set default delay & help-display times" |
170 |
||
92 | 171 |
ShowTime := 15. |
100 | 172 |
DelayTime := 2. |
92 | 173 |
|
174 |
" |
|
175 |
ActiveHelp initialize |
|
176 |
" |
|
233 | 177 |
|
178 |
"Modified: 27.4.1996 / 15:07:27 / cg" |
|
59 | 179 |
! ! |
180 |
||
633 | 181 |
!ActiveHelp class methodsFor:'queries'! |
100 | 182 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
183 |
currentHelpListener |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
184 |
"return the activeHelp listener if activeHelp is turned on, nil otherwise" |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
185 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
186 |
^ TheOneAndOnlyHelpListener |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
187 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
188 |
"Created: 28.6.1997 / 13:59:44 / cg" |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
189 |
! |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
190 |
|
233 | 191 |
isActive |
192 |
"return true, if activeHelp is turned on" |
|
193 |
||
138 | 194 |
^ TheOneAndOnlyHelpListener notNil |
233 | 195 |
|
196 |
"Modified: 27.4.1996 / 15:07:57 / cg" |
|
633 | 197 |
! ! |
198 |
||
199 |
!ActiveHelp class methodsFor:'startup'! |
|
59 | 200 |
|
201 |
start |
|
233 | 202 |
"start activeHelp" |
203 |
||
59 | 204 |
TheOneAndOnlyHelpListener isNil ifTrue:[ |
233 | 205 |
TheOneAndOnlyHelpListener := self new. |
59 | 206 |
]. |
207 |
TheOneAndOnlyHelpListener listen |
|
208 |
||
209 |
" |
|
210 |
ActiveHelp start |
|
211 |
" |
|
233 | 212 |
|
213 |
"Modified: 27.4.1996 / 15:08:05 / cg" |
|
59 | 214 |
! |
215 |
||
216 |
stop |
|
233 | 217 |
"stop activeHelp" |
218 |
||
59 | 219 |
TheOneAndOnlyHelpListener notNil ifTrue:[ |
233 | 220 |
TheOneAndOnlyHelpListener unlisten. |
59 | 221 |
]. |
92 | 222 |
TheOneAndOnlyHelpListener := nil |
59 | 223 |
|
224 |
" |
|
225 |
ActiveHelp stop |
|
226 |
" |
|
233 | 227 |
|
228 |
"Modified: 27.4.1996 / 15:08:11 / cg" |
|
138 | 229 |
! ! |
230 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
231 |
!ActiveHelp class methodsFor:'times'! |
138 | 232 |
|
233 |
delayTime:numberOfSeconds |
|
234 |
"set the delay (the time, the cursor has to be in the view |
|
235 |
before help is shown). The default is 2 seconds." |
|
236 |
||
237 |
DelayTime := numberOfSeconds |
|
238 |
||
239 |
" |
|
240 |
ActiveHelp delayTime:0.5 |
|
241 |
ActiveHelp delayTime:2 |
|
242 |
ActiveHelp delayTime:10 |
|
243 |
" |
|
59 | 244 |
! |
245 |
||
138 | 246 |
showTime:numberOfSeconds |
247 |
"set the number of seconds, a help messages is to be shown. |
|
248 |
The default is 15 seconds." |
|
249 |
||
250 |
ShowTime := numberOfSeconds |
|
251 |
||
252 |
" |
|
253 |
ActiveHelp showTime:10 |
|
254 |
ActiveHelp showTime:99999 |
|
255 |
ActiveHelp showTime:30 |
|
256 |
" |
|
257 |
! ! |
|
258 |
||
259 |
!ActiveHelp methodsFor:'listening'! |
|
260 |
||
261 |
buttonMotion:state x:x y:y view:view |
|
233 | 262 |
"handle motion events - if the mousepointer left the |
263 |
previous helped view, hide the help" |
|
264 |
||
138 | 265 |
self hideIfPointerLeft:view. |
266 |
^ false |
|
233 | 267 |
|
268 |
"Modified: 27.4.1996 / 15:09:48 / cg" |
|
138 | 269 |
! |
270 |
||
271 |
buttonPress:state x:x y:y view:view |
|
233 | 272 |
"handle button press - unconditionally hide the help" |
273 |
||
138 | 274 |
self hideHelp. |
275 |
^ false |
|
233 | 276 |
|
277 |
"Modified: 27.4.1996 / 15:09:45 / cg" |
|
138 | 278 |
! |
279 |
||
280 |
keyPress:state x:x y:y view:view |
|
233 | 281 |
"handle key press - unconditionally hide the help" |
282 |
||
138 | 283 |
self hideHelp. |
284 |
^ false |
|
233 | 285 |
|
286 |
"Modified: 27.4.1996 / 15:09:57 / cg" |
|
138 | 287 |
! |
288 |
||
289 |
pointerEnter:state x:x y:y view:aView |
|
233 | 290 |
"handle pointer entering a view; setup timeOut to show help" |
291 |
||
344 | 292 |
|p| |
138 | 293 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
294 |
self stopHelpDisplayProcess. |
138 | 295 |
self hideIfPointerLeft:aView. |
296 |
aView topView == currentHelpView ifTrue:[ |
|
233 | 297 |
^ true |
138 | 298 |
]. |
299 |
||
300 |
self initiateHelpFor:aView atX:x y:y. |
|
301 |
^ false |
|
233 | 302 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
303 |
"Modified: 28.6.1997 / 14:04:09 / cg" |
138 | 304 |
! |
305 |
||
306 |
pointerLeave:state view:view |
|
233 | 307 |
"handle pointer leaving a view; hide help text" |
308 |
||
138 | 309 |
self hideIfPointerLeft:view. |
310 |
^ false |
|
233 | 311 |
|
312 |
"Modified: 27.4.1996 / 15:10:41 / cg" |
|
59 | 313 |
! ! |
314 |
||
315 |
!ActiveHelp methodsFor:'private'! |
|
316 |
||
317 |
helpTextFor:aView atX:x y:y |
|
233 | 318 |
"retrieve helptext for aView as a string; |
100 | 319 |
walk along the views superView chain, |
320 |
asking models and views encountered while walking. |
|
321 |
The first one who understands and returns a nonNil answer to the |
|
233 | 322 |
#helpTextFor:at: or #helpTextFor: message ends this search and the |
100 | 323 |
returned string is returned." |
324 |
||
602 | 325 |
|model app text view v sv| |
59 | 326 |
|
327 |
view := aView. |
|
328 |
(model := aView model) notNil ifTrue:[ |
|
233 | 329 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
330 |
text := model helpTextFor:aView at:x@y. |
|
331 |
text notNil ifTrue:[^ text]. |
|
332 |
]. |
|
333 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
334 |
text := model helpTextFor:aView. |
|
335 |
text notNil ifTrue:[^ text]. |
|
336 |
] |
|
59 | 337 |
]. |
338 |
||
339 |
(aView respondsTo:#helpText) ifTrue:[ |
|
233 | 340 |
text := aView helpText. |
341 |
text notNil ifTrue:[^ text]. |
|
59 | 342 |
]. |
343 |
||
344 |
"walk up the chain - maybe someone knows about its subview ..." |
|
345 |
v := aView. |
|
346 |
||
296 | 347 |
[(sv := v container) notNil] whileTrue:[ |
233 | 348 |
(model := sv model) notNil ifTrue:[ |
349 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
|
350 |
text := model helpTextFor:aView at:x@y. |
|
351 |
text notNil ifTrue:[^ text]. |
|
352 |
]. |
|
353 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
354 |
text := model helpTextFor:aView. |
|
355 |
text notNil ifTrue:[^ text]. |
|
356 |
] |
|
357 |
]. |
|
59 | 358 |
|
233 | 359 |
(sv respondsTo:#helpTextFor:) ifTrue:[ |
360 |
text := sv helpTextFor:aView. |
|
361 |
text notNil ifTrue:[^ text]. |
|
362 |
text := sv helpTextFor:v. |
|
363 |
text notNil ifTrue:[^ text]. |
|
364 |
]. |
|
602 | 365 |
|
233 | 366 |
v := sv. |
59 | 367 |
]. |
368 |
||
602 | 369 |
(aView respondsTo:#application) ifTrue:[ |
370 |
(app := aView application) notNil ifTrue:[ |
|
371 |
(app respondsTo:#helpTextFor:at:) ifTrue:[ |
|
372 |
text := app helpTextFor:aView at:x@y. |
|
373 |
text notNil ifTrue:[^ text]. |
|
374 |
]. |
|
375 |
(app respondsTo:#helpTextFor:) ifTrue:[ |
|
376 |
text := app helpTextFor:aView. |
|
377 |
text notNil ifTrue:[^ text]. |
|
378 |
] |
|
379 |
] |
|
380 |
]. |
|
381 |
||
100 | 382 |
(v notNil and:[v respondsTo:#application]) ifTrue:[ |
602 | 383 |
(app := v application) notNil ifTrue:[ |
384 |
(app respondsTo:#helpTextFor:at:) ifTrue:[ |
|
385 |
text := app helpTextFor:aView at:x@y. |
|
233 | 386 |
text notNil ifTrue:[^ text]. |
387 |
]. |
|
602 | 388 |
(app respondsTo:#helpTextFor:) ifTrue:[ |
389 |
text := app helpTextFor:aView. |
|
233 | 390 |
text notNil ifTrue:[^ text]. |
391 |
] |
|
392 |
] |
|
100 | 393 |
]. |
394 |
(v notNil and:[v respondsTo:#model]) ifTrue:[ |
|
233 | 395 |
(model := v model) notNil ifTrue:[ |
396 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
|
397 |
text := model helpTextFor:aView at:x@y. |
|
398 |
text notNil ifTrue:[^ text]. |
|
399 |
]. |
|
400 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
401 |
text := model helpTextFor:aView. |
|
402 |
text notNil ifTrue:[^ text]. |
|
403 |
] |
|
404 |
] |
|
100 | 405 |
]. |
406 |
||
59 | 407 |
(view class respondsTo:#helpText) ifTrue:[ |
233 | 408 |
text := view class helpText. |
409 |
text notNil ifTrue:[^ text]. |
|
59 | 410 |
]. |
411 |
||
412 |
^ nil |
|
100 | 413 |
|
414 |
"Modified: 31.8.1995 / 20:38:00 / claus" |
|
296 | 415 |
"Modified: 5.6.1996 / 14:18:23 / cg" |
100 | 416 |
! |
417 |
||
138 | 418 |
hideIfPointerLeft:aView |
233 | 419 |
"hide help, if the pointer is not in aView" |
420 |
||
138 | 421 |
|whereOnScreen p| |
422 |
||
423 |
"/ showProcess notNil ifTrue:[ |
|
424 |
"/ p := showProcess. showProcess := nil. |
|
425 |
"/ p terminate. |
|
426 |
"/ ]. |
|
427 |
||
276 | 428 |
whereOnScreen := aView graphicsDevice pointerPosition. |
138 | 429 |
|
430 |
(currentFrame notNil |
|
431 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
233 | 432 |
self hideHelp. |
433 |
currentView := nil |
|
138 | 434 |
]. |
233 | 435 |
|
276 | 436 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
138 | 437 |
! |
438 |
||
100 | 439 |
initiateHelpFor:aView atX:x y:y |
233 | 440 |
"start a timeout process to display help for aView after some delay" |
441 |
||
100 | 442 |
|text p| |
443 |
||
444 |
text := self helpTextFor:aView atX:x y:y. |
|
445 |
||
446 |
text notNil ifTrue:[ |
|
233 | 447 |
DelayTime > 0 ifTrue:[ |
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
448 |
self stopHelpDisplayProcess. |
233 | 449 |
showProcess := [ |
297 | 450 |
Delay waitForSeconds:DelayTime. |
233 | 451 |
showProcess := nil. |
452 |
self showHelp:text for:aView |
|
453 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
454 |
] ifFalse:[ |
|
455 |
self showHelp:text for:aView |
|
456 |
] |
|
100 | 457 |
]. |
233 | 458 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
459 |
"Modified: 28.6.1997 / 14:05:33 / cg" |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
460 |
! |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
461 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
462 |
stopHelpDisplayProcess |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
463 |
|p| |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
464 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
465 |
showProcess notNil ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
466 |
p := showProcess. showProcess := nil. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
467 |
p terminate. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
468 |
]. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
469 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
470 |
"Created: 28.6.1997 / 14:03:17 / cg" |
59 | 471 |
! ! |
472 |
||
473 |
!ActiveHelp methodsFor:'show / hide help'! |
|
474 |
||
475 |
hideHelp |
|
233 | 476 |
"hide the help text" |
477 |
||
98 | 478 |
|p| |
479 |
||
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
480 |
self stopHelpDisplayProcess. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
481 |
|
59 | 482 |
currentHelpView notNil ifTrue:[ |
233 | 483 |
[ |
484 |
currentHelpView destroy. |
|
485 |
currentHelpView := nil. |
|
486 |
currentView := nil. |
|
487 |
] valueUninterruptably |
|
59 | 488 |
]. |
489 |
currentFrame := nil. |
|
490 |
closeProcess notNil ifTrue:[ |
|
233 | 491 |
p := closeProcess. closeProcess := nil. |
492 |
p terminate. |
|
59 | 493 |
] |
233 | 494 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
495 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
59 | 496 |
! |
497 |
||
498 |
showHelp:aHelpText for:view |
|
233 | 499 |
"show the help text for aView" |
500 |
||
596 | 501 |
|org p v dev top app| |
59 | 502 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
503 |
view == currentView ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
504 |
lastHelpText = aHelpText ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
505 |
^ self |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
506 |
] |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
507 |
]. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
508 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
509 |
lastHelpText := aHelpText. |
59 | 510 |
|
596 | 511 |
"/ give the views application a chance |
512 |
"/ to decide where to show the help text |
|
513 |
"/ (i.e. in its own information area) |
|
514 |
||
515 |
top := view topView. |
|
602 | 516 |
|
517 |
(app := view application) notNil ifTrue:[ |
|
596 | 518 |
(app showHelp:aHelpText for:view) ifTrue:[ |
519 |
^ self |
|
520 |
] |
|
521 |
]. |
|
522 |
||
92 | 523 |
closeProcess notNil ifTrue:[ |
233 | 524 |
p := closeProcess. closeProcess := nil. |
525 |
p terminate. |
|
92 | 526 |
]. |
59 | 527 |
currentHelpView notNil ifTrue:[ |
233 | 528 |
self hideHelp |
59 | 529 |
]. |
530 |
||
531 |
org := view originRelativeTo:nil. |
|
532 |
currentFrame := org extent:view extent. |
|
533 |
org :=org + (view extent // 2). |
|
534 |
||
100 | 535 |
v := ActiveHelpView for:aHelpText withCRs. |
59 | 536 |
|
276 | 537 |
dev := view graphicsDevice. |
538 |
org := dev pointerPosition. |
|
100 | 539 |
org := org + (10@10). |
276 | 540 |
(org x + v width) > dev width ifTrue:[ |
233 | 541 |
org := (org x - v width) @ org y |
92 | 542 |
]. |
276 | 543 |
(org y + v height) > dev height ifTrue:[ |
233 | 544 |
org := org x @ (org y - v height). |
92 | 545 |
]. |
546 |
||
100 | 547 |
v origin:org. |
59 | 548 |
"/ currentHelpView open. |
100 | 549 |
v realize. |
550 |
v enableButtonMotionEvents. |
|
551 |
v enableMotionEvents. |
|
552 |
currentHelpView := v. |
|
59 | 553 |
|
554 |
currentView := view. |
|
555 |
closeProcess := [ |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
556 |
[ |
233 | 557 |
(Delay forSeconds:ShowTime) wait. |
558 |
[ |
|
559 |
currentHelpView notNil ifTrue:[ |
|
560 |
currentHelpView destroy. |
|
561 |
currentHelpView := nil. |
|
562 |
] |
|
563 |
] valueUninterruptably |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
564 |
] valueOnUnwindDo:[ |
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
565 |
closeProcess := nil. |
233 | 566 |
]. |
59 | 567 |
] forkAt:(Processor userSchedulingPriority + 1). |
100 | 568 |
|
569 |
"Modified: 31.8.1995 / 19:20:45 / claus" |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
570 |
"Modified: 28.6.1997 / 14:02:26 / cg" |
59 | 571 |
! ! |
572 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
573 |
!ActiveHelp class methodsFor:'documentation'! |
138 | 574 |
|
575 |
version |
|
633 | 576 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.22 1997-06-28 12:06:53 cg Exp $' |
138 | 577 |
! ! |
59 | 578 |
ActiveHelp initialize! |