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