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