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