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