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