author | penk |
Thu, 15 Nov 2001 12:09:54 +0100 | |
changeset 1529 | 0c9e38ea3261 |
parent 1502 | 487b55dc68c2 |
child 1535 | a9fcabccabb3 |
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 |
||
1502 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
59 | 16 |
EventListener subclass:#ActiveHelp |
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
17 |
instanceVariableNames:'currentView currentHelpView currentFrame showProcess closeProcess |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
18 |
lastHelpText listeningForAll applicationsOrTopViewsWithHelp' |
216 | 19 |
classVariableNames:'DelayTime ShowTime TheOneAndOnlyHelpListener' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Help' |
|
59 | 22 |
! |
23 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
24 |
!ActiveHelp class methodsFor:'documentation'! |
59 | 25 |
|
138 | 26 |
copyright |
27 |
" |
|
28 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
59 | 39 |
! |
40 |
||
41 |
documentation |
|
42 |
" |
|
98 | 43 |
The active help listener. |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
44 |
|
98 | 45 |
The one and only instance of myself intercepts incoming mouse & keyboard |
46 |
events for the display device, being especially interested in view-enter/ |
|
636 | 47 |
leave events. When such an event arrives, it asks the corresponding view |
98 | 48 |
or its model for a help message and display it via an ActiveHelpView. |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
49 |
(actually, the view is first asked if it would like to display it itself |
636 | 50 |
- for example, in some information-view). |
51 |
||
52 |
The query for the helpText is repeated along the views superView chain, |
|
53 |
until any model or view returns a nonNil answer for the #helpTextFor:at |
|
54 |
or #helpTextFor message. |
|
100 | 55 |
|
98 | 56 |
All I need for automatic help is some model/view/applicationModel along |
57 |
the superview chain of the entered component, which responds to the |
|
58 |
#helpTextFor: message with a non-nil (string-) answer. |
|
59 |
I close down the help view after a while, if a key is pressed or the mouse |
|
60 |
moved to another view. |
|
100 | 61 |
|
62 |
Who should provide the helpText: |
|
63 |
||
221 | 64 |
the best place is the application object (an instance of ApplicationModel) |
65 |
or the topView, if its a derived class of StandardSystemView. |
|
66 |
This should know about its components and return the string |
|
67 |
when asked via #helpTextFor:aComponent. |
|
330
d7ce98930ad3
Rename Launcher-->OldLauncher, NewLauncher-->Launcher.
Stefan Vogel <sv@exept.de>
parents:
297
diff
changeset
|
68 |
See examples in FileBrowser, Launcher etc. |
100 | 69 |
|
70 |
Be aware, that for applicationModels, there must be a link from the |
|
71 |
topView to this applicationModel |
|
72 |
(set via: aTopView application:anApplicationModel) |
|
73 |
otherwise, the helpManager has no means of finding the application which |
|
74 |
corresponds to a view. |
|
75 |
||
76 |
Who should display the helpText: |
|
77 |
||
221 | 78 |
by default, the helpListener opens a little popup view, which displays the |
79 |
returned help message. However, a nice trick which can be used by applications |
|
80 |
is to create an infoLabel as a subview of the topFrame (a la windows) |
|
81 |
and display the text right in the #helpTextFor: method. To cheat the |
|
82 |
help listener, this method should then return nil, to keep it silent. |
|
83 |
||
84 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
85 |
Usage: |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
86 |
If help is to be shown for all views (as enabled by the launchers help menu), |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
87 |
use 'ActiveHelp start' and 'ActiveHelp stop'. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
88 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
89 |
Individual apps may enable/disable active help for themself by: |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
90 |
'ActiveHelp startFor:app' or 'ActiveHelp stopFor:app', passing either |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
91 |
the topView or the topViews application as argument. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
92 |
This is usually done by applications which want to show contextHelp in |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
93 |
some infoView. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
94 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
95 |
|
221 | 96 |
[author:] |
97 |
Claus Gittinger |
|
98 |
||
233 | 99 |
[start with:] |
100 |
ActiveHelp start |
|
101 |
ActiveHelp stop |
|
102 |
||
221 | 103 |
[See also:] |
233 | 104 |
ActiveHelpView |
105 |
WindowGroup WindowEvent |
|
106 |
ApplicationModel StandardSystemView |
|
100 | 107 |
" |
108 |
! |
|
109 |
||
110 |
examples |
|
111 |
" |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
112 |
Active Help for a single view |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
113 |
or app (whatever the global settings are): |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
114 |
Can be initiated by an app when its opened. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
115 |
[exBegin] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
116 |
|app top myAppClass| |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
117 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
118 |
Class withoutUpdatingChangesDo:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
119 |
myAppClass := ApplicationModel |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
120 |
subclass:#'Demos::DemoApp' |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
121 |
instanceVariableNames:'' |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
122 |
classVariableNames:'' |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
123 |
poolDictionaries:'' |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
124 |
category:'demos'. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
125 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
126 |
myAppClass |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
127 |
compile:'helpTextFor:aView Transcript showCR:''hello''. ^ ''this is some helpText'''. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
128 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
129 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
130 |
app := myAppClass new. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
131 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
132 |
top := StandardSystemView new. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
133 |
top extent:300@100. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
134 |
top application:app. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
135 |
top open. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
136 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
137 |
ActiveHelp startFor:app. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
138 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
139 |
Class withoutUpdatingChangesDo:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
140 |
myAppClass removeFromSystem |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
141 |
] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
142 |
[exEnd] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
143 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
144 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
145 |
Active Help (for all views): |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
146 |
|
233 | 147 |
(make certain that activeHelp is turned on ... |
148 |
... otherwise, you will see nothing) |
|
100 | 149 |
|
150 |
the following example uses a Plug as a model replacement. |
|
151 |
In concrete application, you would create a method to implement the helpText |
|
152 |
query message. |
|
227 | 153 |
[exBegin] |
154 |
|app top button1 button2| |
|
100 | 155 |
|
227 | 156 |
app := Plug new. |
157 |
app respondTo:#helpTextFor: |
|
158 |
with:[:view | |
|
159 |
view == button1 ifTrue:[ |
|
160 |
'this is button1' |
|
161 |
] ifFalse:[ |
|
162 |
view == button2 ifTrue:[ |
|
163 |
'some help for button2' |
|
164 |
] ifFalse:[ |
|
165 |
nil |
|
166 |
] |
|
167 |
] |
|
168 |
]. |
|
100 | 169 |
|
227 | 170 |
top := StandardSystemView new. |
171 |
top extent:300@100. |
|
172 |
button1 := Button label:'b1' in:top. |
|
173 |
button1 origin:0.0@0.0 corner:0.5@30. |
|
174 |
button2 := Button label:'b2' in:top. |
|
175 |
button2 origin:0.5@0.0 corner:1.0@30. |
|
176 |
top model:app. '<-- normally this would be: top application:app'. |
|
177 |
top open |
|
178 |
[exEnd] |
|
100 | 179 |
|
233 | 180 |
(make certain that activeHelp is turned on ... |
181 |
... otherwise, you will see nothing) |
|
182 |
||
227 | 183 |
alternatively, display of the helpMessage in a local, private view: |
184 |
[exBegin] |
|
185 |
|app top button1 button2 infoView| |
|
100 | 186 |
|
227 | 187 |
app := Plug new. |
188 |
app respondTo:#helpTextFor: |
|
189 |
with:[:view | infoView label:'info ...'. |
|
190 |
view == button1 ifTrue:[ |
|
191 |
infoView label:'this is button1' |
|
192 |
]. |
|
193 |
view == button2 ifTrue:[ |
|
194 |
infoView label:'some help for button2' |
|
195 |
]. |
|
196 |
nil |
|
197 |
]. |
|
100 | 198 |
|
227 | 199 |
top := StandardSystemView new. |
200 |
top extent:300@100. |
|
201 |
button1 := Button label:'b1' in:top. |
|
202 |
button1 origin:0.0@0.0 corner:0.5@30. |
|
203 |
button2 := Button label:'b2' in:top. |
|
204 |
button2 origin:0.5@0.0 corner:1.0@30. |
|
205 |
infoView := Label label:'info ...' in:top. |
|
206 |
infoView level:-1; origin:0.0@1.0 corner:1.0@1.0. |
|
207 |
infoView topInset:(infoView preferredExtent y negated - 3); |
|
208 |
leftInset:3; |
|
209 |
rightInset:3; |
|
210 |
bottomInset:3; |
|
211 |
adjust:#left. |
|
212 |
top model:app. '<-- normally this would be: top application:app'. |
|
213 |
top open |
|
214 |
[exEnd] |
|
59 | 215 |
" |
216 |
! ! |
|
217 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
218 |
!ActiveHelp class methodsFor:'initialization'! |
59 | 219 |
|
220 |
initialize |
|
233 | 221 |
"set default delay & help-display times" |
222 |
||
92 | 223 |
ShowTime := 15. |
100 | 224 |
DelayTime := 2. |
92 | 225 |
|
226 |
" |
|
227 |
ActiveHelp initialize |
|
228 |
" |
|
233 | 229 |
|
230 |
"Modified: 27.4.1996 / 15:07:27 / cg" |
|
59 | 231 |
! ! |
232 |
||
633 | 233 |
!ActiveHelp class methodsFor:'queries'! |
100 | 234 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
235 |
currentHelpListener |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
236 |
"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
|
237 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
238 |
^ TheOneAndOnlyHelpListener |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
239 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
240 |
"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
|
241 |
! |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
242 |
|
233 | 243 |
isActive |
244 |
"return true, if activeHelp is turned on" |
|
245 |
||
138 | 246 |
^ TheOneAndOnlyHelpListener notNil |
233 | 247 |
|
248 |
"Modified: 27.4.1996 / 15:07:57 / cg" |
|
633 | 249 |
! ! |
250 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
251 |
!ActiveHelp class methodsFor:'start & stop'! |
59 | 252 |
|
253 |
start |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
254 |
"start activeHelp for all apps" |
233 | 255 |
|
59 | 256 |
TheOneAndOnlyHelpListener isNil ifTrue:[ |
233 | 257 |
TheOneAndOnlyHelpListener := self new. |
59 | 258 |
]. |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
259 |
TheOneAndOnlyHelpListener listenForAll |
59 | 260 |
|
261 |
" |
|
262 |
ActiveHelp start |
|
263 |
" |
|
233 | 264 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
265 |
"Modified: / 26.10.1997 / 23:16:54 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
266 |
! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
267 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
268 |
startFor:anApplicationOrTopView |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
269 |
"start activeHelp for a single app" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
270 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
271 |
TheOneAndOnlyHelpListener isNil ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
272 |
TheOneAndOnlyHelpListener := self new. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
273 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
274 |
TheOneAndOnlyHelpListener listenFor:anApplicationOrTopView |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
275 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
276 |
"Modified: / 26.10.1997 / 23:17:05 / cg" |
59 | 277 |
! |
278 |
||
279 |
stop |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
280 |
"stop activeHelp for all (except for individual apps)" |
233 | 281 |
|
59 | 282 |
TheOneAndOnlyHelpListener notNil ifTrue:[ |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
283 |
TheOneAndOnlyHelpListener unlistenAll. |
59 | 284 |
]. |
285 |
||
286 |
" |
|
287 |
ActiveHelp stop |
|
288 |
" |
|
233 | 289 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
290 |
"Modified: / 26.10.1997 / 23:18:58 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
291 |
! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
292 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
293 |
stopFor:anAppOrTopView |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
294 |
"stop activeHelp for a single app" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
295 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
296 |
TheOneAndOnlyHelpListener notNil ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
297 |
TheOneAndOnlyHelpListener unlistenFor:anAppOrTopView. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
298 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
299 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
300 |
"Modified: / 26.10.1997 / 23:12:55 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
301 |
"Created: / 26.10.1997 / 23:18:41 / cg" |
138 | 302 |
! ! |
303 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
304 |
!ActiveHelp class methodsFor:'times'! |
138 | 305 |
|
306 |
delayTime:numberOfSeconds |
|
307 |
"set the delay (the time, the cursor has to be in the view |
|
308 |
before help is shown). The default is 2 seconds." |
|
309 |
||
310 |
DelayTime := numberOfSeconds |
|
311 |
||
312 |
" |
|
313 |
ActiveHelp delayTime:0.5 |
|
314 |
ActiveHelp delayTime:2 |
|
315 |
ActiveHelp delayTime:10 |
|
316 |
" |
|
59 | 317 |
! |
318 |
||
138 | 319 |
showTime:numberOfSeconds |
320 |
"set the number of seconds, a help messages is to be shown. |
|
321 |
The default is 15 seconds." |
|
322 |
||
323 |
ShowTime := numberOfSeconds |
|
324 |
||
325 |
" |
|
326 |
ActiveHelp showTime:10 |
|
327 |
ActiveHelp showTime:99999 |
|
328 |
ActiveHelp showTime:30 |
|
329 |
" |
|
330 |
! ! |
|
331 |
||
332 |
!ActiveHelp methodsFor:'listening'! |
|
333 |
||
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
334 |
buttonMotion:state x:x y:y view:aView |
233 | 335 |
"handle motion events - if the mousepointer left the |
336 |
previous helped view, hide the help" |
|
337 |
||
1212 | 338 |
"/ ignore my own help-view |
339 |
aView topView == currentHelpView ifTrue:[ |
|
340 |
^ true |
|
341 |
]. |
|
342 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
343 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
344 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
345 |
] do:[ |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
346 |
|
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
347 |
(self interestedIn:aView) ifTrue:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
348 |
self stopHelpDisplayProcess. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
349 |
self hideIfPointerLeft:aView. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
350 |
self initiateHelpFor:aView atX:x y:y. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
351 |
]. |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
352 |
]. |
138 | 353 |
^ false |
233 | 354 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
355 |
"Modified: / 28.7.1998 / 02:51:51 / cg" |
138 | 356 |
! |
357 |
||
358 |
buttonPress:state x:x y:y view:view |
|
233 | 359 |
"handle button press - unconditionally hide the help" |
360 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
361 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
362 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
363 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
364 |
self hideHelp. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
365 |
]. |
138 | 366 |
^ false |
233 | 367 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
368 |
"Modified: / 28.7.1998 / 02:52:00 / cg" |
138 | 369 |
! |
370 |
||
371 |
keyPress:state x:x y:y view:view |
|
233 | 372 |
"handle key press - unconditionally hide the help" |
373 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
374 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
375 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
376 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
377 |
self hideHelp. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
378 |
]. |
138 | 379 |
^ false |
233 | 380 |
|
381 |
"Modified: 27.4.1996 / 15:09:57 / cg" |
|
138 | 382 |
! |
383 |
||
384 |
pointerEnter:state x:x y:y view:aView |
|
233 | 385 |
"handle pointer entering a view; setup timeOut to show help" |
386 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
387 |
"/ ignore my own help-view |
138 | 388 |
aView topView == currentHelpView ifTrue:[ |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
389 |
^ true |
138 | 390 |
]. |
391 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
392 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
393 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
394 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
395 |
(self interestedIn:aView) ifTrue:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
396 |
self stopHelpDisplayProcess. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
397 |
self hideIfPointerLeft:aView. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
398 |
self initiateHelpFor:aView atX:x y:y. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
399 |
]. |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
400 |
]. |
138 | 401 |
^ false |
233 | 402 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
403 |
"Modified: / 28.7.1998 / 02:52:09 / cg" |
138 | 404 |
! |
405 |
||
406 |
pointerLeave:state view:view |
|
233 | 407 |
"handle pointer leaving a view; hide help text" |
408 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
409 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
410 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
411 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
412 |
self hideIfPointerLeft:view. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
413 |
]. |
138 | 414 |
^ false |
233 | 415 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
416 |
"Modified: / 28.7.1998 / 02:52:16 / cg" |
59 | 417 |
! ! |
418 |
||
419 |
!ActiveHelp methodsFor:'private'! |
|
420 |
||
1502 | 421 |
helpTextFor:aView atX:x y:y |
233 | 422 |
"retrieve helptext for aView as a string; |
100 | 423 |
walk along the views superView chain, |
424 |
asking models and views encountered while walking. |
|
425 |
The first one who understands and returns a nonNil answer to the |
|
233 | 426 |
#helpTextFor:at: or #helpTextFor: message ends this search and the |
100 | 427 |
returned string is returned." |
428 |
||
1100 | 429 |
|model app text view v sv p| |
59 | 430 |
|
431 |
view := aView. |
|
1100 | 432 |
p := x @ y. |
433 |
||
59 | 434 |
(model := aView model) notNil ifTrue:[ |
1502 | 435 |
text := self helpTextFromModel:model view:aView at:p. |
436 |
text notNil ifTrue:[ ^ text ]. |
|
59 | 437 |
]. |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
438 |
(aView respondsTo:#helpTextAt:) ifTrue:[ |
1100 | 439 |
text := aView helpTextAt:p. |
1502 | 440 |
text notNil ifTrue:[ |
441 |
"/ Transcript show: aView class name ; show:' #helpTextAt: -> ' ; showCR:text. |
|
442 |
^ text |
|
443 |
]. |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
444 |
]. |
59 | 445 |
(aView respondsTo:#helpText) ifTrue:[ |
233 | 446 |
text := aView helpText. |
1502 | 447 |
text notNil ifTrue:[ |
448 |
"/ Transcript show: aView class name ; show:' #helpText -> ' ; showCR:text. |
|
449 |
^ text |
|
450 |
]. |
|
59 | 451 |
]. |
452 |
||
453 |
"walk up the chain - maybe someone knows about its subview ..." |
|
454 |
v := aView. |
|
1502 | 455 |
[ |
456 |
(sv := v container) notNil |
|
457 |
] whileTrue:[ |
|
458 |
(model := sv model) notNil ifTrue:[ |
|
459 |
text := self helpTextFromModel:model view:aView at:p. |
|
460 |
text notNil ifTrue:[ ^ text ]. |
|
461 |
]. |
|
462 |
(sv respondsTo:#helpTextFor:) ifTrue:[ |
|
463 |
text := sv helpTextFor:aView. |
|
464 |
text notNil ifTrue:[ ^ text ]. |
|
465 |
text := sv helpTextFor:v. |
|
466 |
text notNil ifTrue:[ ^ text ]. |
|
467 |
]. |
|
468 |
v := sv |
|
233 | 469 |
]. |
602 | 470 |
(aView respondsTo:#application) ifTrue:[ |
471 |
(app := aView application) notNil ifTrue:[ |
|
1502 | 472 |
text := self helpTextFromModel:app view:aView at:p. |
473 |
text notNil ifTrue:[ ^ text ]. |
|
602 | 474 |
] |
475 |
]. |
|
100 | 476 |
(v notNil and:[v respondsTo:#application]) ifTrue:[ |
602 | 477 |
(app := v application) notNil ifTrue:[ |
1502 | 478 |
text := self helpTextFromModel:app view:aView at:p. |
479 |
text notNil ifTrue:[ ^ text ]. |
|
233 | 480 |
] |
100 | 481 |
]. |
482 |
(v notNil and:[v respondsTo:#model]) ifTrue:[ |
|
233 | 483 |
(model := v model) notNil ifTrue:[ |
1502 | 484 |
text := self helpTextFromModel:model view:aView at:p. |
485 |
text notNil ifTrue:[ ^ text ]. |
|
233 | 486 |
] |
100 | 487 |
]. |
59 | 488 |
(view class respondsTo:#helpText) ifTrue:[ |
233 | 489 |
text := view class helpText. |
1502 | 490 |
text notNil ifTrue:[ ^ text ]. |
59 | 491 |
]. |
492 |
^ nil |
|
100 | 493 |
|
728 | 494 |
"Modified: / 31.8.1995 / 20:38:00 / claus" |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
495 |
"Modified: / 28.7.1998 / 01:47:27 / cg" |
100 | 496 |
! |
497 |
||
1502 | 498 |
helpTextFromModel:aModel view:aView at:aPoint |
499 |
"helper: ask aModel for its helpText." |
|
500 |
||
501 |
|text| |
|
502 |
||
503 |
(aModel respondsTo:#helpTextFor:at:) ifTrue:[ |
|
504 |
text := aModel helpTextFor:aView at:aPoint. |
|
505 |
text notNil ifTrue:[ |
|
506 |
"/ Transcript showCR:'model #helpTextFor:at:'. |
|
507 |
^ text |
|
508 |
] |
|
509 |
]. |
|
510 |
(aModel respondsTo:#helpTextFor:) ifTrue:[ |
|
511 |
text := aModel helpTextFor:aView. |
|
512 |
text notNil ifTrue:[ |
|
513 |
"/ Transcript showCR:'model #helpTextFor:'. |
|
514 |
^ text |
|
515 |
] |
|
516 |
]. |
|
517 |
^ nil |
|
518 |
! |
|
519 |
||
138 | 520 |
hideIfPointerLeft:aView |
233 | 521 |
"hide help, if the pointer is not in aView" |
522 |
||
696 | 523 |
|whereOnScreen| |
138 | 524 |
|
1304 | 525 |
currentFrame notNil ifTrue:[ |
526 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
138 | 527 |
|
1304 | 528 |
(currentFrame notNil |
529 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
530 |
self hideHelp. |
|
531 |
currentView := nil |
|
532 |
]. |
|
138 | 533 |
]. |
233 | 534 |
|
276 | 535 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
138 | 536 |
! |
537 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
538 |
interestedIn:aView |
1033
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
539 |
"return true, if I am interested in aView (either listeningForAll, |
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
540 |
or in my list of apps)" |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
541 |
|
1106 | 542 |
|app aViewsTopView| |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
543 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
544 |
listeningForAll == true ifTrue:[^ true]. |
1033
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
545 |
aView isNil ifTrue:[^ false]. |
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
546 |
|
1106 | 547 |
aViewsTopView := aView topView. |
548 |
(applicationsOrTopViewsWithHelp includesIdentical:aViewsTopView) ifTrue:[^ true]. |
|
549 |
app := aViewsTopView application. |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
550 |
app notNil ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
551 |
(applicationsOrTopViewsWithHelp includesIdentical:app) ifTrue:[^ true] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
552 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
553 |
^ false |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
554 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
555 |
"Created: / 26.10.1997 / 23:28:52 / cg" |
1033
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
556 |
"Modified: / 8.8.1998 / 13:36:19 / cg" |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
557 |
! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
558 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
559 |
stopHelpDisplayProcess |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
560 |
|p| |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
561 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
562 |
showProcess notNil ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
563 |
p := showProcess. showProcess := nil. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
564 |
p terminate. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
565 |
]. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
566 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
567 |
"Created: 28.6.1997 / 14:03:17 / cg" |
59 | 568 |
! ! |
569 |
||
570 |
!ActiveHelp methodsFor:'show / hide help'! |
|
571 |
||
572 |
hideHelp |
|
233 | 573 |
"hide the help text" |
574 |
||
98 | 575 |
|p| |
576 |
||
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
577 |
self stopHelpDisplayProcess. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
578 |
|
59 | 579 |
currentHelpView notNil ifTrue:[ |
233 | 580 |
[ |
581 |
currentHelpView destroy. |
|
582 |
currentHelpView := nil. |
|
583 |
currentView := nil. |
|
584 |
] valueUninterruptably |
|
59 | 585 |
]. |
586 |
currentFrame := nil. |
|
587 |
closeProcess notNil ifTrue:[ |
|
233 | 588 |
p := closeProcess. closeProcess := nil. |
589 |
p terminate. |
|
59 | 590 |
] |
233 | 591 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
592 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
59 | 593 |
! |
594 |
||
634 | 595 |
initiateHelpFor:aView atX:x y:y |
596 |
"ask aView for helpText, passing x/y coordinates; |
|
597 |
start a timeout process to display this helpText after some delay; |
|
598 |
Normally used internally, but can also be used by widgets to force |
|
599 |
re-negotiation of the displayed helpText |
|
600 |
(for example in a menu, when the selection changes)" |
|
601 |
||
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
602 |
self |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
603 |
initiateHelpFor:aView atX:x y:y now:false |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
604 |
|
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
605 |
"Modified: 28.6.1997 / 14:45:57 / cg" |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
606 |
! |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
607 |
|
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
608 |
initiateHelpFor:aView atX:x y:y now:showItNow |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
609 |
"ask aView for helpText, passing x/y coordinates; |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
610 |
start a timeout process to display this helpText after some delay; |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
611 |
Normally used internally, but can also be used by widgets to force |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
612 |
re-negotiation of the displayed helpText |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
613 |
(for example in a menu, when the selection changes)" |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
614 |
|
696 | 615 |
|text top app| |
634 | 616 |
|
1143 | 617 |
(self interestedIn:aView) ifFalse:[ |
618 |
^ self |
|
619 |
]. |
|
1142
b223ada4e9f3
allow for nil position in #initiateHelpFor:
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
620 |
x isNil ifTrue:[ |
b223ada4e9f3
allow for nil position in #initiateHelpFor:
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
621 |
text := aView helpText |
b223ada4e9f3
allow for nil position in #initiateHelpFor:
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
622 |
] ifFalse:[ |
b223ada4e9f3
allow for nil position in #initiateHelpFor:
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
623 |
text := self helpTextFor:aView atX:x y:y. |
b223ada4e9f3
allow for nil position in #initiateHelpFor:
Claus Gittinger <cg@exept.de>
parents:
1106
diff
changeset
|
624 |
]. |
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
625 |
lastHelpText = text ifTrue:[ |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
626 |
^ self |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
627 |
]. |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
628 |
|
728 | 629 |
"/ give the views application a chance |
630 |
"/ to decide where to show the help text |
|
631 |
"/ (i.e. in its own information area) |
|
632 |
"/ nil is also passed down, to give it a chance |
|
633 |
"/ to clean its infoDisplay. |
|
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
634 |
|
728 | 635 |
top := aView topView. |
636 |
(app := aView application) notNil ifTrue:[ |
|
1019
862f095da4ac
#showHelp:for: renamed to #showActiveHelp:for:
Claus Gittinger <cg@exept.de>
parents:
1011
diff
changeset
|
637 |
(app showActiveHelp:text for:aView) ifTrue:[ |
728 | 638 |
lastHelpText := text. |
639 |
^ self |
|
640 |
] |
|
641 |
]. |
|
634 | 642 |
|
1143 | 643 |
text size > 0 ifTrue:[ |
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
644 |
(showItNow not and:[DelayTime > 0]) ifTrue:[ |
634 | 645 |
self stopHelpDisplayProcess. |
646 |
showProcess := [ |
|
647 |
Delay waitForSeconds:DelayTime. |
|
648 |
showProcess := nil. |
|
649 |
self showHelp:text for:aView |
|
650 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
651 |
] ifFalse:[ |
|
652 |
self showHelp:text for:aView |
|
653 |
] |
|
654 |
]. |
|
655 |
||
656 |
" |
|
657 |
can be used in a widget as: |
|
658 |
||
659 |
ActiveHelp isActive ifTrue:[ |
|
660 |
ActiveHelp currentHelpListener |
|
661 |
initiateHelpFor:self atX:x y:y |
|
662 |
] |
|
663 |
] |
|
664 |
" |
|
665 |
||
728 | 666 |
"Created: / 28.6.1997 / 14:45:41 / cg" |
1143 | 667 |
"Modified: / 15.3.1999 / 08:38:14 / cg" |
634 | 668 |
! |
669 |
||
59 | 670 |
showHelp:aHelpText for:view |
233 | 671 |
"show the help text for aView" |
672 |
||
696 | 673 |
|org p v dev| |
59 | 674 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
675 |
view == currentView ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
676 |
lastHelpText = aHelpText ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
677 |
^ self |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
678 |
] |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
679 |
]. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
680 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
681 |
lastHelpText := aHelpText. |
59 | 682 |
|
92 | 683 |
closeProcess notNil ifTrue:[ |
233 | 684 |
p := closeProcess. closeProcess := nil. |
685 |
p terminate. |
|
92 | 686 |
]. |
59 | 687 |
currentHelpView notNil ifTrue:[ |
233 | 688 |
self hideHelp |
59 | 689 |
]. |
690 |
||
691 |
org := view originRelativeTo:nil. |
|
692 |
currentFrame := org extent:view extent. |
|
693 |
org :=org + (view extent // 2). |
|
694 |
||
100 | 695 |
v := ActiveHelpView for:aHelpText withCRs. |
59 | 696 |
|
276 | 697 |
dev := view graphicsDevice. |
698 |
org := dev pointerPosition. |
|
100 | 699 |
org := org + (10@10). |
276 | 700 |
(org x + v width) > dev width ifTrue:[ |
233 | 701 |
org := (org x - v width) @ org y |
92 | 702 |
]. |
276 | 703 |
(org y + v height) > dev height ifTrue:[ |
233 | 704 |
org := org x @ (org y - v height). |
92 | 705 |
]. |
706 |
||
100 | 707 |
v origin:org. |
59 | 708 |
"/ currentHelpView open. |
100 | 709 |
v realize. |
710 |
v enableButtonMotionEvents. |
|
711 |
v enableMotionEvents. |
|
712 |
currentHelpView := v. |
|
59 | 713 |
|
714 |
currentView := view. |
|
715 |
closeProcess := [ |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
716 |
[ |
233 | 717 |
(Delay forSeconds:ShowTime) wait. |
718 |
[ |
|
719 |
currentHelpView notNil ifTrue:[ |
|
720 |
currentHelpView destroy. |
|
721 |
currentHelpView := nil. |
|
722 |
] |
|
723 |
] valueUninterruptably |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
724 |
] valueOnUnwindDo:[ |
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
725 |
closeProcess := nil. |
233 | 726 |
]. |
59 | 727 |
] forkAt:(Processor userSchedulingPriority + 1). |
100 | 728 |
|
729 |
"Modified: 31.8.1995 / 19:20:45 / claus" |
|
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
730 |
"Modified: 28.6.1997 / 14:45:15 / cg" |
59 | 731 |
! ! |
732 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
733 |
!ActiveHelp methodsFor:'start & stop'! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
734 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
735 |
listenFor:anAppOrTopView |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
736 |
"start listening" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
737 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
738 |
applicationsOrTopViewsWithHelp isNil ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
739 |
applicationsOrTopViewsWithHelp := WeakIdentitySet new. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
740 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
741 |
applicationsOrTopViewsWithHelp add:anAppOrTopView. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
742 |
super listen. |
639 | 743 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
744 |
"Created: / 26.10.1997 / 23:20:47 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
745 |
"Modified: / 26.10.1997 / 23:21:10 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
746 |
! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
747 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
748 |
listenForAll |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
749 |
"start listening" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
750 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
751 |
listeningForAll := true. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
752 |
super listen. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
753 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
754 |
"Modified: / 28.6.1997 / 15:07:02 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
755 |
"Created: / 26.10.1997 / 23:19:30 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
756 |
! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
757 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
758 |
unlistenAll |
639 | 759 |
"stop listening" |
760 |
||
761 |
self hideHelp. |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
762 |
listeningForAll := false. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
763 |
applicationsOrTopViewsWithHelp size == 0 ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
764 |
super unlisten. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
765 |
] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
766 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
767 |
"Created: / 26.10.1997 / 23:14:17 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
768 |
"Modified: / 26.10.1997 / 23:23:04 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
769 |
! |
639 | 770 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
771 |
unlistenFor:anApp |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
772 |
"stop listening for an app" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
773 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
774 |
self hideHelp. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
775 |
applicationsOrTopViewsWithHelp remove:anApp ifAbsent:nil. |
726 | 776 |
listeningForAll == true ifFalse:[ |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
777 |
applicationsOrTopViewsWithHelp size == 0 ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
778 |
super unlisten. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
779 |
] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
780 |
] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
781 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
782 |
"Created: / 26.10.1997 / 23:22:42 / cg" |
726 | 783 |
"Modified: / 29.10.1997 / 15:48:34 / cg" |
639 | 784 |
! ! |
785 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
786 |
!ActiveHelp class methodsFor:'documentation'! |
138 | 787 |
|
788 |
version |
|
1502 | 789 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.42 2001-09-07 14:39:42 cg Exp $' |
138 | 790 |
! ! |
59 | 791 |
ActiveHelp initialize! |