author | Claus Gittinger <cg@exept.de> |
Wed, 27 Feb 2019 15:56:55 +0100 | |
changeset 4237 | 4c0ddd2ce72e |
parent 4233 | 7bc96946d912 |
child 4252 | ebdd626ee83b |
permissions | -rw-r--r-- |
1802 | 1 |
" |
2 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
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 |
" |
|
1536 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
3656 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1536 | 16 |
ActiveHelp subclass:#FlyByHelp |
4119 | 17 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
18 |
classVariableNames:'MaxNumberOfLines MaxNumberOfColumns' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Help' |
|
1536 | 21 |
! |
22 |
||
4231 | 23 |
Query subclass:#HelpKeyInsteadOfHelpTextQuery |
24 |
instanceVariableNames:'' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:FlyByHelp |
|
28 |
! |
|
29 |
||
1802 | 30 |
!FlyByHelp class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
35 |
All Rights Reserved |
|
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
1893 | 44 |
! |
45 |
||
4055 | 46 |
documentation |
47 |
" |
|
48 |
an instance of me is used to provide tooltips |
|
49 |
(sigh: smalltalk was ahead of its time in the early 90's: |
|
50 |
initially called 'activeHelp', then renamed to 'flyByHelp' |
|
51 |
and now commonly known as tooltip). |
|
52 |
||
53 |
I will watch the mouse movements via an event hook, and determine |
|
54 |
where the mouse pointer is. Then ask the underlying view about its |
|
55 |
helpText and display it in a little floating popup view. |
|
56 |
||
57 |
The hool is installed via: |
|
58 |
FlyByHelp start |
|
59 |
and possibly deactivated/uninstalled via: |
|
60 |
FlyByHelp stop |
|
61 |
||
62 |
There can be only one FlyByHelp at any time - the start/stop methods |
|
63 |
assure that. |
|
64 |
" |
|
65 |
! |
|
66 |
||
1893 | 67 |
examples |
68 |
" |
|
3220 | 69 |
UserPreferences current toolTipShapeStyle:nil |
70 |
UserPreferences current toolTipShapeStyle:#cartoon |
|
71 |
||
1893 | 72 |
FlyByHelp isActive |
73 |
||
74 |
FlyByHelp stop |
|
75 |
FlyByHelp start |
|
76 |
" |
|
1802 | 77 |
! ! |
1536 | 78 |
|
2692 | 79 |
!FlyByHelp class methodsFor:'accessing'! |
80 |
||
81 |
currentlyShownView |
|
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
82 |
TheOneAndOnlyHelpListener isNil ifTrue:[^ nil]. |
2692 | 83 |
^ TheOneAndOnlyHelpListener currentlyShownView |
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
84 |
|
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
85 |
"Modified: / 09-06-2010 / 16:35:48 / cg" |
3255 | 86 |
! |
87 |
||
4231 | 88 |
helpKeyInsteadOfHelpTextQuery |
89 |
^ HelpKeyInsteadOfHelpTextQuery |
|
90 |
||
91 |
"Created: / 22-02-2019 / 09:38:18 / Claus Gittinger" |
|
92 |
! |
|
93 |
||
3255 | 94 |
maxNumberOfColumns |
95 |
^ MaxNumberOfColumns ? 200 |
|
96 |
! |
|
97 |
||
98 |
maxNumberOfLines |
|
99 |
^ MaxNumberOfLines ? 40 |
|
2692 | 100 |
! ! |
101 |
||
2684 | 102 |
!FlyByHelp methodsFor:'defaults'! |
103 |
||
104 |
flyByHelpTimeoutMillis |
|
105 |
"abort flyby help text generation, if no text can be generated within that |
|
106 |
time delta. This is used to abort long-lasting parsing/scanning/analysis in |
|
107 |
large methods when the mouse is moved over some syntactic constructs, and |
|
108 |
it takes too long to parse... |
|
109 |
The returned time is given in ms" |
|
110 |
||
111 |
^ 300 |
|
112 |
! ! |
|
113 |
||
4233 | 114 |
!FlyByHelp methodsFor:'developer menu'! |
115 |
||
116 |
openDeveloperMenuFor:aView at:aPoint |
|
117 |
"with CTRL+SHIFT, this menu appears" |
|
118 |
||
119 |
|app helpText helpKey| |
|
120 |
||
121 |
app := aView topView application. |
|
122 |
app enqueueDelayedAction:[ |
|
123 |
|editor m canDefineTranslationForLabel canDefineTranslationForHelpText| |
|
124 |
||
125 |
m := Menu new. |
|
126 |
m addItem:(MenuItem |
|
127 |
label: 'Edit Resources' |
|
128 |
itemValue:[ |
|
129 |
app enqueueDelayedAction:[ |
|
130 |
app withWaitCursorDo:[ |
|
131 |
editor := Tools::InternationalLanguageTranslationEditor |
|
132 |
openOnPackage:((aView topView application ? aView) class package). |
|
133 |
editor selectOrAddKey:(lastHelpText storeString withoutCRs). |
|
134 |
Transcript showCR:'help text is: %1' with:lastHelpText storeString withoutCRs. |
|
135 |
||
136 |
]. |
|
137 |
]. |
|
138 |
]). |
|
139 |
m addItem:(MenuItem |
|
140 |
label: 'Browse Resources' |
|
141 |
itemValue:[ |
|
142 |
app enqueueDelayedAction:[ |
|
143 |
app withWaitCursorDo:[ |
|
144 |
FileBrowser default |
|
145 |
openOn:(app class projectDefinitionClass |
|
146 |
packageDirectory / 'resources'). |
|
147 |
]. |
|
148 |
]. |
|
149 |
]). |
|
150 |
||
151 |
canDefineTranslationForLabel := |
|
152 |
[ |
|
153 |
(aView isKindOf:Label) or:[aView respondsTo:#label] |
|
154 |
]. |
|
155 |
||
156 |
canDefineTranslationForHelpText := |
|
157 |
[ |
|
158 |
|ok| |
|
159 |
||
160 |
ok := lastHelpText notEmptyOrNil. |
|
161 |
ok := ok or:[ (helpText := aView helpTextAt:aPoint) notEmptyOrNil]. |
|
162 |
ok := ok or:[ (helpText := aView helpText) notEmptyOrNil]. |
|
163 |
ok := ok or:[ (helpKey := aView helpKey) notNil]. |
|
164 |
ok := ok or:[ (helpText := app helpTextFor:aView) notEmptyOrNil ]. |
|
165 |
ok |
|
166 |
]. |
|
167 |
||
168 |
m addItem:(MenuItem |
|
169 |
label: 'Define Translation for Label...' |
|
170 |
itemValue:[ |
|
171 |
|package key | |
|
172 |
||
173 |
key := aView label asString string. |
|
174 |
package := app class package. |
|
175 |
ResourcePack defineResourceFor:key package:package. |
|
176 |
] |
|
177 |
enabled:canDefineTranslationForLabel). |
|
178 |
m addItem:(MenuItem |
|
179 |
label: 'Define Translation for Helptext...' |
|
180 |
itemValue:[ |
|
181 |
|package key | |
|
182 |
||
183 |
key := (lastHelpText ? helpText ? helpKey) asString string. |
|
184 |
package := app class package. |
|
185 |
ResourcePack defineResourceFor:key package:package. |
|
186 |
] |
|
187 |
enabled:canDefineTranslationForHelpText). |
|
188 |
||
189 |
m addSeparator. |
|
190 |
m addItem:(MenuItem |
|
191 |
label: 'Browse Application' |
|
192 |
itemValue:[ SystemBrowser default openInClass:aView application class]). |
|
193 |
||
194 |
m addItem:(MenuItem |
|
195 |
label: 'UI Painter' |
|
196 |
itemValue:[ UIPainter openOnClass:aView application class andSelector:#windowSpec]). |
|
197 |
||
198 |
aView application ~~ app ifTrue:[ |
|
199 |
m addSeparator. |
|
200 |
m addItem:(MenuItem |
|
201 |
label: 'Browse Top Application' |
|
202 |
itemValue:[ SystemBrowser default openInClass:app class]). |
|
203 |
||
204 |
m addItem:(MenuItem |
|
205 |
label: 'UI Painter on Top Application' |
|
206 |
itemValue:[ UIPainter openOnClass:app class andSelector:#windowSpec]). |
|
207 |
]. |
|
208 |
||
209 |
m showAtPointer. |
|
210 |
]. |
|
211 |
||
212 |
"Created: / 22-02-2019 / 09:32:35 / Claus Gittinger" |
|
213 |
! ! |
|
214 |
||
2392 | 215 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 216 |
|
2474 | 217 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 218 |
aView == currentHelpView ifTrue:[ |
219 |
"/ the help-bubble itself |
|
220 |
^ false |
|
221 |
]. |
|
222 |
||
4055 | 223 |
"/ don't start tooltip, if this view is not active. |
224 |
"/ The following line does not work, because motion events are reported for the current focus-view, |
|
3321 | 225 |
"/ which is always active. Must check after we have determined the view under the pointer |
3675 | 226 |
"/ aView topView isActive ifFalse:[^ false]. |
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
227 |
|
2474 | 228 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 229 |
! |
230 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
231 |
buttonPress:button x:x y:y view:aView |
3198 | 232 |
|prevView| |
233 |
||
234 |
"/ hideHelp nils the currentView |
|
235 |
"/ we restore it, so the tooltip is not shown again for this view |
|
236 |
"/ until the mouse really leaves the view |
|
237 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
238 |
prevView := currentView. |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
239 |
self hideHelp. |
3198 | 240 |
currentView := prevView. |
241 |
||
242 |
^ false |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
243 |
|
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
244 |
"Modified: / 23-12-2011 / 20:37:28 / cg" |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
245 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
246 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
247 |
keyPress:key x:x y:y view:aView |
4226 | 248 |
<resource: #keyboard (#Escape #Control #Shift)> |
3216 | 249 |
|
4228 | 250 |
|prevView text| |
3198 | 251 |
|
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
252 |
currentHelpView notNil ifTrue:[ |
4237 | 253 |
key == $§ ifTrue:[ |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
254 |
"/ generate a line suitable for the resources file (a null translation) |
3216 | 255 |
"/ into the clipboard; makes it easy to add missing translations to a .rs file, |
4082 | 256 |
"/ by pressing paragraph whenever you see an untranslated helptext |
4228 | 257 |
text := (lastHelpText storeString withoutCRs, ' ' , lastHelpText storeString withoutCRs). |
258 |
aView setClipboardText:text. |
|
2612 | 259 |
self hideHelp. |
4230 | 260 |
^ false |
2612 | 261 |
]. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
262 |
key == #Escape ifTrue:[ |
3198 | 263 |
prevView := currentView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
264 |
self hideHelp. |
3198 | 265 |
currentView := prevView. |
4230 | 266 |
^ false |
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
267 |
]. |
4228 | 268 |
(#(#'Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[ |
269 |
aView device ctrlDown ifTrue:[ |
|
4230 | 270 |
self hideHelp. |
4231 | 271 |
self openDeveloperMenuFor:aView at:x@y |
4230 | 272 |
]. |
273 |
^ false |
|
4228 | 274 |
]. |
275 |
||
276 |
(#(#'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
4226 | 277 |
"/ reopen showing the key |
278 |
self initiateHelpFor:aView at:(x@y) now:true. |
|
4230 | 279 |
^ false |
4226 | 280 |
]. |
281 |
||
282 |
(#('Shift' #'Shift_L' #'Shift_R' #'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
3216 | 283 |
"/ do not close on those... |
284 |
^ false |
|
285 |
]. |
|
4226 | 286 |
]. |
3198 | 287 |
|
288 |
"/ hideHelp nils the currentView |
|
289 |
"/ we restore it, so the tooltip is not shown again for this view |
|
290 |
"/ until the mouse really leaves the view |
|
291 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
292 |
prevView := currentView. |
|
293 |
self hideHelpIgnoringErrors. |
|
294 |
currentView := prevView. |
|
295 |
||
296 |
^ false |
|
297 |
"/ ^ super keyPress:key x:x y:y view:aView |
|
2884
7d37f5a0719e
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2878
diff
changeset
|
298 |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
299 |
"Modified (format): / 25-12-2011 / 10:25:23 / cg" |
4082 | 300 |
"Modified (format): / 16-04-2018 / 16:53:15 / stefan" |
4231 | 301 |
"Modified: / 22-02-2019 / 09:32:28 / Claus Gittinger" |
4226 | 302 |
! |
303 |
||
304 |
keyRelease:key x:x y:y view:aView |
|
305 |
<resource: #keyboard (#Control)> |
|
306 |
||
307 |
currentHelpView notNil ifTrue:[ |
|
308 |
(#(#'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
309 |
"/ reopen showing the text |
|
310 |
self initiateHelpFor:aView at:(x@y) now:true. |
|
311 |
^ true |
|
312 |
]. |
|
313 |
(#('Shift' #'Shift_L' #'Shift_R' #'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
314 |
"/ do not close on those... |
|
315 |
^ false |
|
316 |
]. |
|
317 |
]. |
|
318 |
^ super keyRelease:key x:x y:y view:aView |
|
319 |
||
320 |
"Created: / 20-02-2019 / 11:26:19 / Claus Gittinger" |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
321 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
322 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
323 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
324 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
325 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
326 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
327 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
328 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
329 |
|
1540 | 330 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
331 |
aView == currentHelpView ifTrue:[^ true]. |
3198 | 332 |
|
333 |
"/ clear the do-not-show-in-this-view mode (see keyPress) |
|
334 |
"/ (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil]. |
|
335 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
336 |
^ super pointerLeave:state view:aView |
1540 | 337 |
! ! |
338 |
||
2392 | 339 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 340 |
|
341 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
342 |
"helper: ask aModel for its helpText." |
|
343 |
||
344 |
|text| |
|
345 |
||
4048 | 346 |
(aPointOrNil notNil and:[aModel respondsTo:#helpTextFor:at:]) ifTrue:[ |
347 |
text := aModel helpTextFor:aView at:aPointOrNil. |
|
4121 | 348 |
text notNil ifTrue:[ |
349 |
"/ Transcript showCR:aModel. |
|
350 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
351 |
^ text |
|
352 |
]. |
|
1536 | 353 |
]. |
4048 | 354 |
(aModel respondsTo:#helpTextFor:) ifTrue:[ |
355 |
text := aModel helpTextFor:aView. |
|
4121 | 356 |
text notNil ifTrue:[ |
357 |
"/ Transcript showCR:aModel. |
|
358 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
359 |
^ text |
|
360 |
]. |
|
1536 | 361 |
]. |
2754 | 362 |
^ nil |
4040 | 363 |
|
364 |
"Modified: / 09-01-2018 / 17:35:26 / stefan" |
|
4121 | 365 |
"Modified: / 11-06-2018 / 09:53:40 / Claus Gittinger" |
1536 | 366 |
! |
367 |
||
368 |
helpTextFromView:aView at:aPointOrNil |
|
369 |
"helper: ask aView for its helpText." |
|
370 |
||
2754 | 371 |
|text key app| |
1536 | 372 |
|
4121 | 373 |
"/ is there any view which does not understand helpTextAt: ??? |
4048 | 374 |
(aPointOrNil notNil and:[aView respondsTo:#helpTextAt:]) ifTrue:[ |
375 |
text := aView helpTextAt:aPointOrNil. |
|
4121 | 376 |
text notNil ifTrue:[ |
377 |
"/ Transcript showCR:'via helpTextAt:'; showCR:text. |
|
378 |
^ text |
|
379 |
]. |
|
1536 | 380 |
]. |
4121 | 381 |
"/ is there any view which does not understand helpText ??? |
4048 | 382 |
(aView respondsTo:#helpText) ifTrue:[ |
383 |
text := aView helpText. |
|
4121 | 384 |
text notNil ifTrue:[ |
385 |
"/ Transcript showCR:'via helpText'; showCR:text. |
|
4220 | 386 |
^ text value |
4121 | 387 |
]. |
2754 | 388 |
]. |
3804 | 389 |
"/ to be enabled in next release... |
390 |
"/ (aView superView notNil |
|
4048 | 391 |
"/ and:[aView superView respondsTo:#helpTextFor:]) ifTrue:[ |
392 |
"/ text := aView superView helpTextFor:aView. |
|
3804 | 393 |
"/ text notNil ifTrue:[^ text]. |
394 |
"/ ]. |
|
4121 | 395 |
|
396 |
"/ is there any view which does not understand helpKey ??? |
|
2754 | 397 |
(aView respondsTo:#helpKey) ifTrue:[ |
398 |
key := aView helpKey. |
|
399 |
key notNil ifTrue:[ |
|
400 |
app := aView application. |
|
401 |
app isNil ifTrue:[ |
|
4175 | 402 |
|topView topViewsHelpSpec| |
403 |
||
3763 | 404 |
"/ special case for oldStyle Dialog subclasses. |
4175 | 405 |
topView := aView topView. |
406 |
(topViewsHelpSpec := topView helpSpec) notNil ifTrue:[ |
|
407 |
text := topViewsHelpSpec at:key ifAbsent:nil. |
|
3763 | 408 |
text notNil ifTrue:[ |
4121 | 409 |
"/ Transcript showCR:'via topViewspec+helpKey'; showCR:text. |
4175 | 410 |
^ topView resources stringWithCRs:text. |
3763 | 411 |
]. |
412 |
]. |
|
2754 | 413 |
app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ]. |
414 |
]. |
|
415 |
app notNil ifTrue:[ |
|
4121 | 416 |
text := app helpTextForKey:key. |
417 |
true "text notNil" ifTrue:[ |
|
418 |
"/ Transcript showCR:'via helpKey+helpTextForKey:'; showCR:text. |
|
419 |
^ text |
|
420 |
]. |
|
2754 | 421 |
]. |
4121 | 422 |
text := aView resources string:key. |
423 |
true "(text notNil and:[text ~= key])" ifTrue:[ |
|
424 |
"/ Transcript showCR:'via helpKey'; showCR:text. |
|
4110 | 425 |
^ text |
426 |
] |
|
1536 | 427 |
]. |
428 |
]. |
|
2754 | 429 |
^ nil. |
4040 | 430 |
|
431 |
"Modified: / 09-01-2018 / 17:38:42 / stefan" |
|
4111 | 432 |
"Modified (format): / 07-06-2018 / 09:51:41 / sr" |
4220 | 433 |
"Modified: / 07-02-2019 / 19:18:39 / Claus Gittinger" |
2392 | 434 |
! ! |
435 |
||
4119 | 436 |
!FlyByHelp methodsFor:'queries'! |
437 |
||
438 |
currentlyShownView |
|
439 |
^ currentHelpView |
|
440 |
! |
|
441 |
||
442 |
toolTipFollowsMouse |
|
443 |
"if true, the tooltip-window moves with the pointer |
|
444 |
so that it stays away from (does not cover) the mouse pointer" |
|
445 |
||
446 |
^ false |
|
447 |
||
448 |
"Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger" |
|
449 |
! ! |
|
450 |
||
451 |
!FlyByHelp methodsFor:'show & hide help'! |
|
452 |
||
453 |
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice |
|
454 |
applicationOrNil notNil ifTrue:[ |
|
455 |
^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice |
|
456 |
]. |
|
457 |
^ ActiveHelpView for:helpText onDevice:aDevice. |
|
458 |
||
459 |
" |
|
460 |
(ActiveHelpView for:'Hello' onDevice:Display) open |
|
461 |
" |
|
462 |
! |
|
463 |
||
464 |
hideHelp |
|
465 |
"hide the help text" |
|
466 |
||
467 |
|p| |
|
468 |
||
469 |
"/ lastHelpText := nil. |
|
470 |
self stopHelpDisplayProcess. |
|
471 |
lastHelpText := nil. |
|
472 |
||
473 |
currentHelpView notNil ifTrue:[ |
|
474 |
[ |
|
475 |
currentHelpView notNil ifTrue:[ |
|
476 |
currentHelpView destroy. |
|
477 |
currentHelpView := nil. |
|
478 |
currentView := nil. |
|
479 |
] |
|
480 |
] valueUninterruptably |
|
481 |
]. |
|
482 |
currentFrame := nil. |
|
483 |
(p := closeProcess) notNil ifTrue:[ |
|
484 |
closeProcess := nil. |
|
485 |
p terminate. |
|
486 |
] |
|
487 |
||
488 |
"Modified: / 28-06-1997 / 14:03:50 / cg" |
|
489 |
"Modified: / 16-04-2018 / 16:51:01 / stefan" |
|
490 |
! |
|
1536 | 491 |
|
492 |
hideIfPointerLeft:aView |
|
493 |
"hide help, if the pointer is not in aView" |
|
494 |
||
4119 | 495 |
|helpFrame whereOnScreen| |
1536 | 496 |
|
4119 | 497 |
(helpFrame := currentFrame) notNil ifTrue:[ |
1536 | 498 |
whereOnScreen := aView graphicsDevice pointerPosition. |
499 |
||
4119 | 500 |
((helpFrame insetBy:1@1) containsPoint:whereOnScreen) ifFalse:[ |
1536 | 501 |
self hideHelp. |
4119 | 502 |
] ifTrue:[ |
503 |
pointerPositionAtShowTime notNil ifTrue:[ |
|
504 |
(whereOnScreen dist:pointerPositionAtShowTime) > 10 ifTrue:[ |
|
505 |
self hideHelp. |
|
506 |
]. |
|
507 |
]. |
|
508 |
]. |
|
1536 | 509 |
]. |
510 |
||
4082 | 511 |
"Modified: / 28-05-1996 / 20:18:28 / cg" |
512 |
"Modified: / 16-04-2018 / 16:59:48 / stefan" |
|
4119 | 513 |
"Modified: / 08-06-2018 / 10:30:04 / Claus Gittinger" |
1536 | 514 |
! |
515 |
||
516 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
517 |
"ask aView for helpText, passing x/y coordinates; |
|
518 |
start a timeout process to display this helpText after some delay; |
|
519 |
Normally used internally, but can also be used by widgets to force |
|
520 |
re-negotiation of the displayed helpText |
|
521 |
(for example in a menu, when the selection changes)" |
|
522 |
||
4110 | 523 |
|text delayTime| |
1536 | 524 |
|
525 |
(self interestedIn:aView) ifFalse:[ |
|
4237 | 526 |
Debugging ifTrue:[ |
527 |
'not interested' infoPrintCR |
|
528 |
]. |
|
1536 | 529 |
^ self |
530 |
]. |
|
531 |
||
2680 | 532 |
"/ do not allow for more than 200 ms to be spent in the |
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
533 |
"/ helpText gatherer (the codeView parses the code for the variable under the cursor) |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
534 |
[ |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
535 |
Error handle:[:ex | |
3394 | 536 |
('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR. |
3675 | 537 |
Transcript showCR:'-------------------------'. |
3394 | 538 |
ex suspendedContext fullPrintAllOn:Transcript. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
539 |
"/ self halt. |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
540 |
] do:[ |
4231 | 541 |
HelpKeyInsteadOfHelpTextQuery answer:(aView device ctrlDown) do:[ |
542 |
text := self helpTextFor:aView at:aPointOrNil. |
|
543 |
]. |
|
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
544 |
]. |
3656 | 545 |
] valueWithWatchDog:[ |
546 |
'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR. |
|
547 |
^ self |
|
548 |
] afterMilliseconds:(self flyByHelpTimeoutMillis). |
|
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
549 |
|
4110 | 550 |
false ifTrue:[ |
551 |
(text notNil and:[text isEmpty]) ifTrue:[ |
|
552 |
Logger warning:('empty help from: ',aView class printString) |
|
553 |
] ifFalse:[ |
|
554 |
text isEmptyOrNil ifTrue:[ |
|
555 |
Logger warning:('no help from: ',aView class printString) |
|
556 |
]. |
|
557 |
]. |
|
558 |
]. |
|
559 |
||
4082 | 560 |
(lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[ |
4237 | 561 |
Debugging == true ifTrue:[ |
562 |
'same text: ' infoPrint. text infoPrintCR. |
|
563 |
]. |
|
4082 | 564 |
self toolTipFollowsMouse ifFalse:[ |
565 |
^ self |
|
2392 | 566 |
] |
1536 | 567 |
]. |
568 |
||
4110 | 569 |
((text size > 0) or:[text notNil and:[text isString not]]) ifTrue:[ |
2778 | 570 |
(showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[ |
1536 | 571 |
self stopHelpDisplayProcess. |
2392 | 572 |
showProcess := |
573 |
[ |
|
2680 | 574 |
Delay waitForSeconds:delayTime. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
575 |
[ |
3766 | 576 |
aView device notNil ifTrue:[ |
577 |
aView device anyButtonPressed ifFalse:[ |
|
578 |
showProcess := nil. |
|
579 |
self showHelp:text for:aView |
|
580 |
] |
|
581 |
]. |
|
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
582 |
] ensure:[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
583 |
showProcess := nil. |
2680 | 584 |
] |
2392 | 585 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 586 |
] ifFalse:[ |
587 |
self showHelp:text for:aView |
|
588 |
] |
|
1542 | 589 |
] ifFalse:[ |
590 |
self hideHelp |
|
1536 | 591 |
]. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
592 |
|
2901
fed697afcef8
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
593 |
"Modified: / 22-03-2011 / 19:10:28 / cg" |
4082 | 594 |
"Modified: / 16-04-2018 / 12:20:33 / stefan" |
4237 | 595 |
"Modified: / 27-02-2019 / 11:28:52 / Claus Gittinger" |
1536 | 596 |
! |
597 |
||
598 |
showHelp:aHelpText for:view |
|
599 |
"show the help text for aView" |
|
600 |
||
3786 | 601 |
|wg applicationOrNil org p v device helpTextShown textLines |
3334 | 602 |
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight |
4119 | 603 |
showTime cursorView pos pointerPosition| |
1536 | 604 |
|
2781 | 605 |
"/ thisContext fullPrintAllOn:Transcript. |
2651 | 606 |
(wg := view windowGroup) notNil ifTrue:[ |
607 |
wg isInModalLoop ifTrue:[ |
|
608 |
wg isModal ifFalse:[ |
|
609 |
^ self |
|
610 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
611 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
612 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
613 |
|
3786 | 614 |
device := view graphicsDevice. |
4119 | 615 |
pointerPosition := device pointerPosition. |
616 |
||
3418 | 617 |
"/ mouse still over that view? |
4119 | 618 |
cursorView := device viewFromPoint:pointerPosition. |
3418 | 619 |
cursorView ~~ view ifTrue:[ |
620 |
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ]. |
|
621 |
^ self |
|
622 |
]. |
|
623 |
||
4082 | 624 |
(view == currentView and:[lastHelpText = aHelpText]) ifTrue:[ |
625 |
^ self |
|
1536 | 626 |
]. |
4119 | 627 |
|
628 |
pointerPositionAtShowTime := pointerPosition. |
|
3228 | 629 |
lastHelpWidget := view. |
1536 | 630 |
lastHelpText := aHelpText. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
631 |
helpTextShown := aHelpText. |
4129 | 632 |
|
3257 | 633 |
"/ the text originator must already have generated CRs; |
4114 | 634 |
"/ no longer done here (otherwise, we could not generate tooltips with Windows filenames in it) |
3681 | 635 |
textLines := helpTextShown isStringCollection |
636 |
ifTrue:[helpTextShown] |
|
3767 | 637 |
ifFalse:[ |
638 |
helpTextShown isString |
|
4129 | 639 |
ifTrue:[helpTextShown asCollectionOfLines asStringCollection] |
3767 | 640 |
ifFalse:[nil]]. |
641 |
textLines notNil ifTrue:[ |
|
642 |
textLines size > (self class maxNumberOfLines) ifTrue:[ |
|
643 |
textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...' |
|
644 |
]. |
|
645 |
textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)]. |
|
646 |
helpTextShown := textLines asString. |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
647 |
]. |
3767 | 648 |
|
2780 | 649 |
(p := closeProcess) notNil ifTrue:[ |
650 |
closeProcess := nil. |
|
1536 | 651 |
p terminate. |
652 |
]. |
|
653 |
currentHelpView notNil ifTrue:[ |
|
654 |
self hideHelp |
|
655 |
]. |
|
656 |
||
3770 | 657 |
"/ Transcript showCR:helpTextShown storeString. |
3769 | 658 |
helpTextShown isEmptyOrNil ifTrue:[^ self]. |
659 |
||
1536 | 660 |
org := view originRelativeTo:nil. |
661 |
currentFrame := org extent:view extent. |
|
2848 | 662 |
org := org + (view extent // 2). |
1536 | 663 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
664 |
wg notNil ifTrue:[ applicationOrNil := wg application ]. |
3786 | 665 |
v := self activeHelpViewForApplication:applicationOrNil text:helpTextShown onDevice:device. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
666 |
v perform:#controllingHelpListener: with:self ifNotUnderstood:[]. |
1536 | 667 |
|
2848 | 668 |
helpViewWidth := v width. |
669 |
helpViewHeight := v height. |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
670 |
|
4082 | 671 |
"https://expeccoalm.exept.de/D226383: keep the help window away from the pointer under any circumstances |
672 |
(especially when the window touches the bottom or the right edge of the screen). |
|
673 |
When the pointer is no longer in the current window, the help window is closed!!" |
|
674 |
pos := device pointerPosition. |
|
675 |
org := pos + (10@18). |
|
3786 | 676 |
monitorBounds := device monitorBoundsAt:org. |
3114 | 677 |
usableWidth := monitorBounds width - 2. |
3786 | 678 |
usableHeight := device usableHeightAt:org. |
3114 | 679 |
|
680 |
helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)]. |
|
3247 | 681 |
helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)]. |
3114 | 682 |
|
683 |
(org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[ |
|
4082 | 684 |
org x:(monitorBounds left + usableWidth - helpViewWidth). |
1536 | 685 |
]. |
3114 | 686 |
(org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[ |
4082 | 687 |
org y:(monitorBounds top + usableHeight - helpViewHeight). |
1536 | 688 |
]. |
4082 | 689 |
((org extent:v extent) containsPoint:pos) ifTrue:[ |
690 |
"pointer would be in the help window (see comment above). |
|
691 |
Help window is at the lower right edge. Move it to the left of the pointer" |
|
692 |
org x:(pos x - helpViewWidth - 20). |
|
693 |
]. |
|
1536 | 694 |
v origin:org. |
695 |
v realize. |
|
696 |
currentHelpView := v. |
|
2392 | 697 |
currentView := view. |
1536 | 698 |
|
3334 | 699 |
showTime := self showTime. |
4082 | 700 |
(showTime > 0) ifTrue:[ |
3959 | 701 |
p := |
702 |
[ |
|
1546 | 703 |
[ |
4082 | 704 |
Delay waitForSeconds:showTime. |
2392 | 705 |
[ |
2780 | 706 |
|v| |
707 |
(v := currentHelpView) notNil ifTrue:[ |
|
2392 | 708 |
currentHelpView := nil. |
2780 | 709 |
v destroy. |
2392 | 710 |
] |
711 |
] valueUninterruptably |
|
712 |
] ifCurtailed:[ |
|
3959 | 713 |
(p == closeProcess) ifTrue:[ closeProcess := nil ]. |
2392 | 714 |
]. |
715 |
] newProcess. |
|
3959 | 716 |
p priority:(Processor userSchedulingPriority + 1). |
717 |
closeProcess := p. |
|
718 |
p resume. |
|
2392 | 719 |
]. |
1536 | 720 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
721 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
3959 | 722 |
"Modified: / 06-06-2017 / 15:06:41 / cg" |
4082 | 723 |
"Modified (format): / 16-04-2018 / 17:29:10 / stefan" |
4119 | 724 |
"Modified: / 08-06-2018 / 10:28:32 / Claus Gittinger" |
4129 | 725 |
"Modified (format): / 14-06-2018 / 08:29:43 / Claus Gittinger" |
1536 | 726 |
! |
727 |
||
728 |
stopHelpDisplayProcess |
|
729 |
|p| |
|
730 |
||
2680 | 731 |
(p := showProcess) notNil ifTrue:[ |
732 |
showProcess := nil. |
|
1536 | 733 |
p terminate. |
734 |
]. |
|
735 |
||
736 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
737 |
! ! |
|
738 |
||
4231 | 739 |
!FlyByHelp::HelpKeyInsteadOfHelpTextQuery class methodsFor:'documentation'! |
740 |
||
741 |
documentation |
|
742 |
" |
|
743 |
kludge to force application to return the helpKey instead of the |
|
744 |
help text. |
|
745 |
Answering true will tell the ApplicationModel to return the key. |
|
746 |
(see AppModel >> helpTextForKey:) |
|
747 |
||
748 |
[author:] |
|
749 |
Claus Gittinger |
|
750 |
||
751 |
[instance variables:] |
|
752 |
||
753 |
[class variables:] |
|
754 |
||
755 |
[see also:] |
|
756 |
||
757 |
" |
|
758 |
! ! |
|
759 |
||
760 |
!FlyByHelp::HelpKeyInsteadOfHelpTextQuery methodsFor:'defaults'! |
|
761 |
||
762 |
defaultResumeValue |
|
763 |
^ false |
|
764 |
||
765 |
"Created: / 22-02-2019 / 09:48:28 / Claus Gittinger" |
|
766 |
! ! |
|
767 |
||
1536 | 768 |
!FlyByHelp class methodsFor:'documentation'! |
769 |
||
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
770 |
version |
3656 | 771 |
^ '$Header$' |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
772 |
! |
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
773 |
|
2754 | 774 |
version_CVS |
3656 | 775 |
^ '$Header$' |
1536 | 776 |
! ! |
3114 | 777 |