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