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