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