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