author | Claus Gittinger <cg@exept.de> |
Tue, 08 Sep 1998 13:26:51 +0200 | |
changeset 1066 | 3f827dd8983f |
parent 1048 | 84719be68422 |
child 1100 | 5f25636fad8c |
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 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
336 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
337 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
338 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
339 |
"/ ignore my own help-view |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
340 |
aView topView == currentHelpView ifTrue:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
341 |
^ true |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
342 |
]. |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
343 |
|
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
344 |
(self interestedIn:aView) ifTrue:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
345 |
self stopHelpDisplayProcess. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
346 |
self hideIfPointerLeft:aView. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
347 |
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
|
348 |
]. |
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
349 |
]. |
138 | 350 |
^ false |
233 | 351 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
352 |
"Modified: / 28.7.1998 / 02:51:51 / cg" |
138 | 353 |
! |
354 |
||
355 |
buttonPress:state x:x y:y view:view |
|
233 | 356 |
"handle button press - unconditionally hide the help" |
357 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
358 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
359 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
360 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
361 |
self hideHelp. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
362 |
]. |
138 | 363 |
^ false |
233 | 364 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
365 |
"Modified: / 28.7.1998 / 02:52:00 / cg" |
138 | 366 |
! |
367 |
||
368 |
keyPress:state x:x y:y view:view |
|
233 | 369 |
"handle key press - unconditionally hide the help" |
370 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
371 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
372 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
373 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
374 |
self hideHelp. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
375 |
]. |
138 | 376 |
^ false |
233 | 377 |
|
378 |
"Modified: 27.4.1996 / 15:09:57 / cg" |
|
138 | 379 |
! |
380 |
||
381 |
pointerEnter:state x:x y:y view:aView |
|
233 | 382 |
"handle pointer entering a view; setup timeOut to show help" |
383 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
384 |
"/ ignore my own help-view |
138 | 385 |
aView topView == currentHelpView ifTrue:[ |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
386 |
^ true |
138 | 387 |
]. |
388 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
389 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
390 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
391 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
392 |
(self interestedIn:aView) ifTrue:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
393 |
self stopHelpDisplayProcess. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
394 |
self hideIfPointerLeft:aView. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
395 |
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
|
396 |
]. |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
397 |
]. |
138 | 398 |
^ false |
233 | 399 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
400 |
"Modified: / 28.7.1998 / 02:52:09 / cg" |
138 | 401 |
! |
402 |
||
403 |
pointerLeave:state view:view |
|
233 | 404 |
"handle pointer leaving a view; hide help text" |
405 |
||
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
406 |
Object errorSignal handle:[:ex | |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
407 |
ex return |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
408 |
] do:[ |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
409 |
self hideIfPointerLeft:view. |
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
410 |
]. |
138 | 411 |
^ false |
233 | 412 |
|
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
413 |
"Modified: / 28.7.1998 / 02:52:16 / cg" |
59 | 414 |
! ! |
415 |
||
416 |
!ActiveHelp methodsFor:'private'! |
|
417 |
||
418 |
helpTextFor:aView atX:x y:y |
|
233 | 419 |
"retrieve helptext for aView as a string; |
100 | 420 |
walk along the views superView chain, |
421 |
asking models and views encountered while walking. |
|
422 |
The first one who understands and returns a nonNil answer to the |
|
233 | 423 |
#helpTextFor:at: or #helpTextFor: message ends this search and the |
100 | 424 |
returned string is returned." |
425 |
||
602 | 426 |
|model app text view v sv| |
59 | 427 |
|
428 |
view := aView. |
|
429 |
(model := aView model) notNil ifTrue:[ |
|
233 | 430 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
431 |
text := model helpTextFor:aView at:x@y. |
|
432 |
text notNil ifTrue:[^ text]. |
|
433 |
]. |
|
434 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
435 |
text := model helpTextFor:aView. |
|
436 |
text notNil ifTrue:[^ text]. |
|
437 |
] |
|
59 | 438 |
]. |
439 |
||
1011
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
440 |
(aView respondsTo:#helpTextAt:) ifTrue:[ |
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
441 |
text := aView helpTextAt:x@y. |
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
442 |
text notNil ifTrue:[^ text]. |
53514f2c18a7
also ask for helpTextAt:, when a motionEvent arrives.
Claus Gittinger <cg@exept.de>
parents:
728
diff
changeset
|
443 |
]. |
59 | 444 |
(aView respondsTo:#helpText) ifTrue:[ |
233 | 445 |
text := aView helpText. |
446 |
text notNil ifTrue:[^ text]. |
|
59 | 447 |
]. |
448 |
||
449 |
"walk up the chain - maybe someone knows about its subview ..." |
|
450 |
v := aView. |
|
451 |
||
296 | 452 |
[(sv := v container) notNil] whileTrue:[ |
233 | 453 |
(model := sv model) notNil ifTrue:[ |
454 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
|
455 |
text := model helpTextFor:aView at:x@y. |
|
456 |
text notNil ifTrue:[^ text]. |
|
457 |
]. |
|
458 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
459 |
text := model helpTextFor:aView. |
|
460 |
text notNil ifTrue:[^ text]. |
|
461 |
] |
|
462 |
]. |
|
59 | 463 |
|
233 | 464 |
(sv respondsTo:#helpTextFor:) ifTrue:[ |
465 |
text := sv helpTextFor:aView. |
|
466 |
text notNil ifTrue:[^ text]. |
|
467 |
text := sv helpTextFor:v. |
|
468 |
text notNil ifTrue:[^ text]. |
|
469 |
]. |
|
602 | 470 |
|
233 | 471 |
v := sv. |
59 | 472 |
]. |
473 |
||
602 | 474 |
(aView respondsTo:#application) ifTrue:[ |
475 |
(app := aView application) notNil ifTrue:[ |
|
476 |
(app respondsTo:#helpTextFor:at:) ifTrue:[ |
|
477 |
text := app helpTextFor:aView at:x@y. |
|
478 |
text notNil ifTrue:[^ text]. |
|
479 |
]. |
|
480 |
(app respondsTo:#helpTextFor:) ifTrue:[ |
|
481 |
text := app helpTextFor:aView. |
|
482 |
text notNil ifTrue:[^ text]. |
|
483 |
] |
|
484 |
] |
|
485 |
]. |
|
486 |
||
100 | 487 |
(v notNil and:[v respondsTo:#application]) ifTrue:[ |
602 | 488 |
(app := v application) notNil ifTrue:[ |
489 |
(app respondsTo:#helpTextFor:at:) ifTrue:[ |
|
490 |
text := app helpTextFor:aView at:x@y. |
|
233 | 491 |
text notNil ifTrue:[^ text]. |
492 |
]. |
|
602 | 493 |
(app respondsTo:#helpTextFor:) ifTrue:[ |
494 |
text := app helpTextFor:aView. |
|
233 | 495 |
text notNil ifTrue:[^ text]. |
496 |
] |
|
497 |
] |
|
100 | 498 |
]. |
499 |
(v notNil and:[v respondsTo:#model]) ifTrue:[ |
|
233 | 500 |
(model := v model) notNil ifTrue:[ |
501 |
(model respondsTo:#helpTextFor:at:) ifTrue:[ |
|
502 |
text := model helpTextFor:aView at:x@y. |
|
503 |
text notNil ifTrue:[^ text]. |
|
504 |
]. |
|
505 |
(model respondsTo:#helpTextFor:) ifTrue:[ |
|
506 |
text := model helpTextFor:aView. |
|
507 |
text notNil ifTrue:[^ text]. |
|
508 |
] |
|
509 |
] |
|
100 | 510 |
]. |
511 |
||
59 | 512 |
(view class respondsTo:#helpText) ifTrue:[ |
233 | 513 |
text := view class helpText. |
514 |
text notNil ifTrue:[^ text]. |
|
59 | 515 |
]. |
516 |
||
517 |
^ nil |
|
100 | 518 |
|
728 | 519 |
"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
|
520 |
"Modified: / 28.7.1998 / 01:47:27 / cg" |
100 | 521 |
! |
522 |
||
138 | 523 |
hideIfPointerLeft:aView |
233 | 524 |
"hide help, if the pointer is not in aView" |
525 |
||
696 | 526 |
|whereOnScreen| |
138 | 527 |
|
276 | 528 |
whereOnScreen := aView graphicsDevice pointerPosition. |
138 | 529 |
|
530 |
(currentFrame notNil |
|
531 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
233 | 532 |
self hideHelp. |
533 |
currentView := nil |
|
138 | 534 |
]. |
233 | 535 |
|
276 | 536 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
138 | 537 |
! |
538 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
539 |
interestedIn:aView |
1033
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
540 |
"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
|
541 |
or in my list of apps)" |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
542 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
543 |
|app| |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
544 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
545 |
listeningForAll == true ifTrue:[^ true]. |
1033
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
546 |
aView isNil ifTrue:[^ false]. |
3a56ba930052
care for nil view passed to #interestedIn.
Claus Gittinger <cg@exept.de>
parents:
1019
diff
changeset
|
547 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
548 |
(applicationsOrTopViewsWithHelp includesIdentical:(aView topView)) ifTrue:[^ true]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
549 |
app := aView topView application. |
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 |
|
617 |
text := self helpTextFor:aView atX:x y:y. |
|
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
618 |
lastHelpText = text ifTrue:[ |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
619 |
^ self |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
620 |
]. |
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
621 |
|
728 | 622 |
"/ give the views application a chance |
623 |
"/ to decide where to show the help text |
|
624 |
"/ (i.e. in its own information area) |
|
625 |
"/ nil is also passed down, to give it a chance |
|
626 |
"/ to clean its infoDisplay. |
|
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
627 |
|
728 | 628 |
top := aView topView. |
629 |
(app := aView application) notNil ifTrue:[ |
|
1019
862f095da4ac
#showHelp:for: renamed to #showActiveHelp:for:
Claus Gittinger <cg@exept.de>
parents:
1011
diff
changeset
|
630 |
(app showActiveHelp:text for:aView) ifTrue:[ |
728 | 631 |
lastHelpText := text. |
632 |
^ self |
|
633 |
] |
|
634 |
]. |
|
634 | 635 |
|
728 | 636 |
text notNil ifTrue:[ |
637
8be64da7d932
views own help display is done immediately.
Claus Gittinger <cg@exept.de>
parents:
636
diff
changeset
|
637 |
(showItNow not and:[DelayTime > 0]) ifTrue:[ |
634 | 638 |
self stopHelpDisplayProcess. |
639 |
showProcess := [ |
|
640 |
Delay waitForSeconds:DelayTime. |
|
641 |
showProcess := nil. |
|
642 |
self showHelp:text for:aView |
|
643 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
644 |
] ifFalse:[ |
|
645 |
self showHelp:text for:aView |
|
646 |
] |
|
647 |
]. |
|
648 |
||
649 |
" |
|
650 |
can be used in a widget as: |
|
651 |
||
652 |
ActiveHelp isActive ifTrue:[ |
|
653 |
ActiveHelp currentHelpListener |
|
654 |
initiateHelpFor:self atX:x y:y |
|
655 |
] |
|
656 |
] |
|
657 |
" |
|
658 |
||
728 | 659 |
"Created: / 28.6.1997 / 14:45:41 / cg" |
1019
862f095da4ac
#showHelp:for: renamed to #showActiveHelp:for:
Claus Gittinger <cg@exept.de>
parents:
1011
diff
changeset
|
660 |
"Modified: / 31.7.1998 / 18:25:28 / cg" |
634 | 661 |
! |
662 |
||
59 | 663 |
showHelp:aHelpText for:view |
233 | 664 |
"show the help text for aView" |
665 |
||
696 | 666 |
|org p v dev| |
59 | 667 |
|
632
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
668 |
view == currentView ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
669 |
lastHelpText = aHelpText ifTrue:[ |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
670 |
^ self |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
671 |
] |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
672 |
]. |
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
673 |
|
844b1aaf3eeb
provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents:
602
diff
changeset
|
674 |
lastHelpText := aHelpText. |
59 | 675 |
|
92 | 676 |
closeProcess notNil ifTrue:[ |
233 | 677 |
p := closeProcess. closeProcess := nil. |
678 |
p terminate. |
|
92 | 679 |
]. |
59 | 680 |
currentHelpView notNil ifTrue:[ |
233 | 681 |
self hideHelp |
59 | 682 |
]. |
683 |
||
684 |
org := view originRelativeTo:nil. |
|
685 |
currentFrame := org extent:view extent. |
|
686 |
org :=org + (view extent // 2). |
|
687 |
||
100 | 688 |
v := ActiveHelpView for:aHelpText withCRs. |
59 | 689 |
|
276 | 690 |
dev := view graphicsDevice. |
691 |
org := dev pointerPosition. |
|
100 | 692 |
org := org + (10@10). |
276 | 693 |
(org x + v width) > dev width ifTrue:[ |
233 | 694 |
org := (org x - v width) @ org y |
92 | 695 |
]. |
276 | 696 |
(org y + v height) > dev height ifTrue:[ |
233 | 697 |
org := org x @ (org y - v height). |
92 | 698 |
]. |
699 |
||
100 | 700 |
v origin:org. |
59 | 701 |
"/ currentHelpView open. |
100 | 702 |
v realize. |
703 |
v enableButtonMotionEvents. |
|
704 |
v enableMotionEvents. |
|
705 |
currentHelpView := v. |
|
59 | 706 |
|
707 |
currentView := view. |
|
708 |
closeProcess := [ |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
709 |
[ |
233 | 710 |
(Delay forSeconds:ShowTime) wait. |
711 |
[ |
|
712 |
currentHelpView notNil ifTrue:[ |
|
713 |
currentHelpView destroy. |
|
714 |
currentHelpView := nil. |
|
715 |
] |
|
716 |
] valueUninterruptably |
|
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
717 |
] valueOnUnwindDo:[ |
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
718 |
closeProcess := nil. |
233 | 719 |
]. |
59 | 720 |
] forkAt:(Processor userSchedulingPriority + 1). |
100 | 721 |
|
722 |
"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
|
723 |
"Modified: 28.6.1997 / 14:45:15 / cg" |
59 | 724 |
! ! |
725 |
||
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
726 |
!ActiveHelp methodsFor:'start & stop'! |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
727 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
728 |
listenFor:anAppOrTopView |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
729 |
"start listening" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
730 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
731 |
applicationsOrTopViewsWithHelp isNil ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
732 |
applicationsOrTopViewsWithHelp := WeakIdentitySet new. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
733 |
]. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
734 |
applicationsOrTopViewsWithHelp add:anAppOrTopView. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
735 |
super listen. |
639 | 736 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
737 |
"Created: / 26.10.1997 / 23:20:47 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
738 |
"Modified: / 26.10.1997 / 23:21:10 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
739 |
! |
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 |
listenForAll |
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 |
listeningForAll := true. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
745 |
super listen. |
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 |
"Modified: / 28.6.1997 / 15:07:02 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
748 |
"Created: / 26.10.1997 / 23:19:30 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
749 |
! |
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 |
unlistenAll |
639 | 752 |
"stop listening" |
753 |
||
754 |
self hideHelp. |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
755 |
listeningForAll := false. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
756 |
applicationsOrTopViewsWithHelp size == 0 ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
757 |
super unlisten. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
758 |
] |
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 |
"Created: / 26.10.1997 / 23:14:17 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
761 |
"Modified: / 26.10.1997 / 23:23:04 / cg" |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
762 |
! |
639 | 763 |
|
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
764 |
unlistenFor:anApp |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
765 |
"stop listening for an app" |
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 |
self hideHelp. |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
768 |
applicationsOrTopViewsWithHelp remove:anApp ifAbsent:nil. |
726 | 769 |
listeningForAll == true ifFalse:[ |
719
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
770 |
applicationsOrTopViewsWithHelp size == 0 ifTrue:[ |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
771 |
super unlisten. |
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 |
] |
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
774 |
|
17fba5c2a167
allow applications to start activeHelp for
Claus Gittinger <cg@exept.de>
parents:
696
diff
changeset
|
775 |
"Created: / 26.10.1997 / 23:22:42 / cg" |
726 | 776 |
"Modified: / 29.10.1997 / 15:48:34 / cg" |
639 | 777 |
! ! |
778 |
||
338
071f92621e3b
oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents:
330
diff
changeset
|
779 |
!ActiveHelp class methodsFor:'documentation'! |
138 | 780 |
|
781 |
version |
|
1048
84719be68422
catch error while doing active help - since this is done
Claus Gittinger <cg@exept.de>
parents:
1033
diff
changeset
|
782 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.35 1998-08-19 13:38:41 cg Exp $' |
138 | 783 |
! ! |
59 | 784 |
ActiveHelp initialize! |