author | Claus Gittinger <cg@exept.de> |
Thu, 14 Jun 2018 00:19:41 +0200 | |
changeset 4125 | 7d349e2afa0e |
parent 4121 | c9c15ae83c1c |
child 4129 | f6e152e7c328 |
permissions | -rw-r--r-- |
4110 | 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 |
4119 | 19 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
20 |
classVariableNames:'MaxNumberOfLines MaxNumberOfColumns' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Help' |
|
1536 | 23 |
! |
24 |
||
1802 | 25 |
!FlyByHelp class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
1893 | 39 |
! |
40 |
||
4055 | 41 |
documentation |
42 |
" |
|
43 |
an instance of me is used to provide tooltips |
|
44 |
(sigh: smalltalk was ahead of its time in the early 90's: |
|
45 |
initially called 'activeHelp', then renamed to 'flyByHelp' |
|
46 |
and now commonly known as tooltip). |
|
47 |
||
48 |
I will watch the mouse movements via an event hook, and determine |
|
49 |
where the mouse pointer is. Then ask the underlying view about its |
|
50 |
helpText and display it in a little floating popup view. |
|
51 |
||
52 |
The hool is installed via: |
|
53 |
FlyByHelp start |
|
54 |
and possibly deactivated/uninstalled via: |
|
55 |
FlyByHelp stop |
|
56 |
||
57 |
There can be only one FlyByHelp at any time - the start/stop methods |
|
58 |
assure that. |
|
59 |
" |
|
60 |
! |
|
61 |
||
1893 | 62 |
examples |
63 |
" |
|
3220 | 64 |
UserPreferences current toolTipShapeStyle:nil |
65 |
UserPreferences current toolTipShapeStyle:#cartoon |
|
66 |
||
1893 | 67 |
FlyByHelp isActive |
68 |
||
69 |
FlyByHelp stop |
|
70 |
FlyByHelp start |
|
71 |
" |
|
1802 | 72 |
! ! |
1536 | 73 |
|
2692 | 74 |
!FlyByHelp class methodsFor:'accessing'! |
75 |
||
76 |
currentlyShownView |
|
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
77 |
TheOneAndOnlyHelpListener isNil ifTrue:[^ nil]. |
2692 | 78 |
^ TheOneAndOnlyHelpListener currentlyShownView |
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
79 |
|
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
80 |
"Modified: / 09-06-2010 / 16:35:48 / cg" |
3255 | 81 |
! |
82 |
||
83 |
maxNumberOfColumns |
|
84 |
^ MaxNumberOfColumns ? 200 |
|
85 |
! |
|
86 |
||
87 |
maxNumberOfLines |
|
88 |
^ MaxNumberOfLines ? 40 |
|
2692 | 89 |
! ! |
90 |
||
2684 | 91 |
!FlyByHelp methodsFor:'defaults'! |
92 |
||
93 |
flyByHelpTimeoutMillis |
|
94 |
"abort flyby help text generation, if no text can be generated within that |
|
95 |
time delta. This is used to abort long-lasting parsing/scanning/analysis in |
|
96 |
large methods when the mouse is moved over some syntactic constructs, and |
|
97 |
it takes too long to parse... |
|
98 |
The returned time is given in ms" |
|
99 |
||
100 |
^ 300 |
|
101 |
! ! |
|
102 |
||
2392 | 103 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 104 |
|
2474 | 105 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 106 |
aView == currentHelpView ifTrue:[ |
107 |
"/ the help-bubble itself |
|
108 |
^ false |
|
109 |
]. |
|
110 |
||
4055 | 111 |
"/ don't start tooltip, if this view is not active. |
112 |
"/ The following line does not work, because motion events are reported for the current focus-view, |
|
3321 | 113 |
"/ which is always active. Must check after we have determined the view under the pointer |
3675 | 114 |
"/ aView topView isActive ifFalse:[^ false]. |
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
115 |
|
2474 | 116 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 117 |
! |
118 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
119 |
buttonPress:button x:x y:y view:aView |
3198 | 120 |
|prevView| |
121 |
||
122 |
"/ hideHelp nils the currentView |
|
123 |
"/ we restore it, so the tooltip is not shown again for this view |
|
124 |
"/ until the mouse really leaves the view |
|
125 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
126 |
prevView := currentView. |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
127 |
self hideHelp. |
3198 | 128 |
currentView := prevView. |
129 |
||
130 |
^ false |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
131 |
|
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
132 |
"Modified: / 23-12-2011 / 20:37:28 / cg" |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
133 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
134 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
135 |
keyPress:key x:x y:y view:aView |
3216 | 136 |
<resource: #keyboard (#Escape)> |
137 |
||
3198 | 138 |
|prevView| |
139 |
||
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
140 |
currentHelpView notNil ifTrue:[ |
4110 | 141 |
key == $§ ifTrue:[ |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
142 |
"/ generate a line suitable for the resources file (a null translation) |
3216 | 143 |
"/ into the clipboard; makes it easy to add missing translations to a .rs file, |
4082 | 144 |
"/ by pressing paragraph whenever you see an untranslated helptext |
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
145 |
aView setClipboardText:(lastHelpText storeString , ' ' , lastHelpText storeString). |
2612 | 146 |
self hideHelp. |
147 |
^ true |
|
148 |
]. |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
149 |
key == #Escape ifTrue:[ |
3198 | 150 |
prevView := currentView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
151 |
self hideHelp. |
3198 | 152 |
currentView := prevView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
153 |
^ true |
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
154 |
]. |
3216 | 155 |
(#('Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[ |
156 |
"/ do not close on those... |
|
157 |
^ false |
|
158 |
]. |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
159 |
]. |
3198 | 160 |
|
161 |
"/ hideHelp nils the currentView |
|
162 |
"/ we restore it, so the tooltip is not shown again for this view |
|
163 |
"/ until the mouse really leaves the view |
|
164 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
165 |
prevView := currentView. |
|
166 |
self hideHelpIgnoringErrors. |
|
167 |
currentView := prevView. |
|
168 |
||
169 |
^ false |
|
170 |
"/ ^ 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
|
171 |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
172 |
"Modified (format): / 25-12-2011 / 10:25:23 / cg" |
4082 | 173 |
"Modified (format): / 16-04-2018 / 16:53:15 / stefan" |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
174 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
175 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
176 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
177 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
178 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
179 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
180 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
181 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
182 |
|
1540 | 183 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
184 |
aView == currentHelpView ifTrue:[^ true]. |
3198 | 185 |
|
186 |
"/ clear the do-not-show-in-this-view mode (see keyPress) |
|
187 |
"/ (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil]. |
|
188 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
189 |
^ super pointerLeave:state view:aView |
1540 | 190 |
! ! |
191 |
||
2392 | 192 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 193 |
|
194 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
195 |
"helper: ask aModel for its helpText." |
|
196 |
||
197 |
|text| |
|
198 |
||
4048 | 199 |
(aPointOrNil notNil and:[aModel respondsTo:#helpTextFor:at:]) ifTrue:[ |
200 |
text := aModel helpTextFor:aView at:aPointOrNil. |
|
4121 | 201 |
text notNil ifTrue:[ |
202 |
"/ Transcript showCR:aModel. |
|
203 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
204 |
^ text |
|
205 |
]. |
|
1536 | 206 |
]. |
4048 | 207 |
(aModel respondsTo:#helpTextFor:) ifTrue:[ |
208 |
text := aModel helpTextFor:aView. |
|
4121 | 209 |
text notNil ifTrue:[ |
210 |
"/ Transcript showCR:aModel. |
|
211 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
212 |
^ text |
|
213 |
]. |
|
1536 | 214 |
]. |
2754 | 215 |
^ nil |
4040 | 216 |
|
217 |
"Modified: / 09-01-2018 / 17:35:26 / stefan" |
|
4121 | 218 |
"Modified: / 11-06-2018 / 09:53:40 / Claus Gittinger" |
1536 | 219 |
! |
220 |
||
221 |
helpTextFromView:aView at:aPointOrNil |
|
222 |
"helper: ask aView for its helpText." |
|
223 |
||
2754 | 224 |
|text key app| |
1536 | 225 |
|
4121 | 226 |
"/ is there any view which does not understand helpTextAt: ??? |
4048 | 227 |
(aPointOrNil notNil and:[aView respondsTo:#helpTextAt:]) ifTrue:[ |
228 |
text := aView helpTextAt:aPointOrNil. |
|
4121 | 229 |
text notNil ifTrue:[ |
230 |
"/ Transcript showCR:'via helpTextAt:'; showCR:text. |
|
231 |
^ text |
|
232 |
]. |
|
1536 | 233 |
]. |
4121 | 234 |
"/ is there any view which does not understand helpText ??? |
4048 | 235 |
(aView respondsTo:#helpText) ifTrue:[ |
236 |
text := aView helpText. |
|
4121 | 237 |
text notNil ifTrue:[ |
238 |
"/ Transcript showCR:'via helpText'; showCR:text. |
|
239 |
^ text |
|
240 |
]. |
|
2754 | 241 |
]. |
3804 | 242 |
"/ to be enabled in next release... |
243 |
"/ (aView superView notNil |
|
4048 | 244 |
"/ and:[aView superView respondsTo:#helpTextFor:]) ifTrue:[ |
245 |
"/ text := aView superView helpTextFor:aView. |
|
3804 | 246 |
"/ text notNil ifTrue:[^ text]. |
247 |
"/ ]. |
|
4121 | 248 |
|
249 |
"/ is there any view which does not understand helpKey ??? |
|
2754 | 250 |
(aView respondsTo:#helpKey) ifTrue:[ |
251 |
key := aView helpKey. |
|
252 |
key notNil ifTrue:[ |
|
253 |
app := aView application. |
|
254 |
app isNil ifTrue:[ |
|
3763 | 255 |
"/ special case for oldStyle Dialog subclasses. |
4048 | 256 |
aView topView helpSpec notNil ifTrue:[ |
257 |
text := aView topView helpSpec at:key ifAbsent:nil. |
|
3763 | 258 |
text notNil ifTrue:[ |
4121 | 259 |
"/ Transcript showCR:'via topViewspec+helpKey'; showCR:text. |
3763 | 260 |
^ aView topView resources stringWithCRs:text. |
261 |
]. |
|
262 |
]. |
|
2754 | 263 |
app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ]. |
264 |
]. |
|
265 |
app notNil ifTrue:[ |
|
4121 | 266 |
text := app helpTextForKey:key. |
267 |
true "text notNil" ifTrue:[ |
|
268 |
"/ Transcript showCR:'via helpKey+helpTextForKey:'; showCR:text. |
|
269 |
^ text |
|
270 |
]. |
|
2754 | 271 |
]. |
4121 | 272 |
text := aView resources string:key. |
273 |
true "(text notNil and:[text ~= key])" ifTrue:[ |
|
274 |
"/ Transcript showCR:'via helpKey'; showCR:text. |
|
4110 | 275 |
^ text |
276 |
] |
|
1536 | 277 |
]. |
278 |
]. |
|
2754 | 279 |
^ nil. |
4040 | 280 |
|
281 |
"Modified: / 09-01-2018 / 17:38:42 / stefan" |
|
4111 | 282 |
"Modified (format): / 07-06-2018 / 09:51:41 / sr" |
4121 | 283 |
"Modified: / 11-06-2018 / 09:53:53 / Claus Gittinger" |
2392 | 284 |
! ! |
285 |
||
4119 | 286 |
!FlyByHelp methodsFor:'queries'! |
287 |
||
288 |
currentlyShownView |
|
289 |
^ currentHelpView |
|
290 |
! |
|
291 |
||
292 |
toolTipFollowsMouse |
|
293 |
"if true, the tooltip-window moves with the pointer |
|
294 |
so that it stays away from (does not cover) the mouse pointer" |
|
295 |
||
296 |
^ false |
|
297 |
||
298 |
"Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger" |
|
299 |
! ! |
|
300 |
||
301 |
!FlyByHelp methodsFor:'show & hide help'! |
|
302 |
||
303 |
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice |
|
304 |
applicationOrNil notNil ifTrue:[ |
|
305 |
^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice |
|
306 |
]. |
|
307 |
^ ActiveHelpView for:helpText onDevice:aDevice. |
|
308 |
||
309 |
" |
|
310 |
(ActiveHelpView for:'Hello' onDevice:Display) open |
|
311 |
" |
|
312 |
! |
|
313 |
||
314 |
hideHelp |
|
315 |
"hide the help text" |
|
316 |
||
317 |
|p| |
|
318 |
||
319 |
"/ lastHelpText := nil. |
|
320 |
self stopHelpDisplayProcess. |
|
321 |
lastHelpText := nil. |
|
322 |
||
323 |
currentHelpView notNil ifTrue:[ |
|
324 |
[ |
|
325 |
currentHelpView notNil ifTrue:[ |
|
326 |
currentHelpView destroy. |
|
327 |
currentHelpView := nil. |
|
328 |
currentView := nil. |
|
329 |
] |
|
330 |
] valueUninterruptably |
|
331 |
]. |
|
332 |
currentFrame := nil. |
|
333 |
(p := closeProcess) notNil ifTrue:[ |
|
334 |
closeProcess := nil. |
|
335 |
p terminate. |
|
336 |
] |
|
337 |
||
338 |
"Modified: / 28-06-1997 / 14:03:50 / cg" |
|
339 |
"Modified: / 16-04-2018 / 16:51:01 / stefan" |
|
340 |
! |
|
1536 | 341 |
|
342 |
hideIfPointerLeft:aView |
|
343 |
"hide help, if the pointer is not in aView" |
|
344 |
||
4119 | 345 |
|helpFrame whereOnScreen| |
1536 | 346 |
|
4119 | 347 |
(helpFrame := currentFrame) notNil ifTrue:[ |
1536 | 348 |
whereOnScreen := aView graphicsDevice pointerPosition. |
349 |
||
4119 | 350 |
((helpFrame insetBy:1@1) containsPoint:whereOnScreen) ifFalse:[ |
1536 | 351 |
self hideHelp. |
4119 | 352 |
] ifTrue:[ |
353 |
pointerPositionAtShowTime notNil ifTrue:[ |
|
354 |
(whereOnScreen dist:pointerPositionAtShowTime) > 10 ifTrue:[ |
|
355 |
self hideHelp. |
|
356 |
]. |
|
357 |
]. |
|
358 |
]. |
|
1536 | 359 |
]. |
360 |
||
4082 | 361 |
"Modified: / 28-05-1996 / 20:18:28 / cg" |
362 |
"Modified: / 16-04-2018 / 16:59:48 / stefan" |
|
4119 | 363 |
"Modified: / 08-06-2018 / 10:30:04 / Claus Gittinger" |
1536 | 364 |
! |
365 |
||
366 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
367 |
"ask aView for helpText, passing x/y coordinates; |
|
368 |
start a timeout process to display this helpText after some delay; |
|
369 |
Normally used internally, but can also be used by widgets to force |
|
370 |
re-negotiation of the displayed helpText |
|
371 |
(for example in a menu, when the selection changes)" |
|
372 |
||
4110 | 373 |
|text delayTime| |
1536 | 374 |
|
375 |
(self interestedIn:aView) ifFalse:[ |
|
376 |
^ self |
|
377 |
]. |
|
378 |
||
2680 | 379 |
"/ 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
|
380 |
"/ 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
|
381 |
[ |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
382 |
Error handle:[:ex | |
3394 | 383 |
('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR. |
3675 | 384 |
Transcript showCR:'-------------------------'. |
3394 | 385 |
ex suspendedContext fullPrintAllOn:Transcript. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
386 |
"/ self halt. |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
387 |
] do:[ |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
388 |
text := self helpTextFor:aView at:aPointOrNil. |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
389 |
]. |
3656 | 390 |
] valueWithWatchDog:[ |
391 |
'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR. |
|
392 |
^ self |
|
393 |
] afterMilliseconds:(self flyByHelpTimeoutMillis). |
|
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
394 |
|
4110 | 395 |
false ifTrue:[ |
396 |
(text notNil and:[text isEmpty]) ifTrue:[ |
|
397 |
Logger warning:('empty help from: ',aView class printString) |
|
398 |
] ifFalse:[ |
|
399 |
text isEmptyOrNil ifTrue:[ |
|
400 |
Logger warning:('no help from: ',aView class printString) |
|
401 |
]. |
|
402 |
]. |
|
403 |
]. |
|
404 |
||
4082 | 405 |
(lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[ |
406 |
self toolTipFollowsMouse ifFalse:[ |
|
407 |
^ self |
|
2392 | 408 |
] |
1536 | 409 |
]. |
410 |
||
4110 | 411 |
((text size > 0) or:[text notNil and:[text isString not]]) ifTrue:[ |
2778 | 412 |
(showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[ |
1536 | 413 |
self stopHelpDisplayProcess. |
2392 | 414 |
showProcess := |
415 |
[ |
|
2680 | 416 |
Delay waitForSeconds:delayTime. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
417 |
[ |
3766 | 418 |
aView device notNil ifTrue:[ |
419 |
aView device anyButtonPressed ifFalse:[ |
|
420 |
showProcess := nil. |
|
421 |
self showHelp:text for:aView |
|
422 |
] |
|
423 |
]. |
|
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
424 |
] ensure:[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
425 |
showProcess := nil. |
2680 | 426 |
] |
2392 | 427 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 428 |
] ifFalse:[ |
429 |
self showHelp:text for:aView |
|
430 |
] |
|
1542 | 431 |
] ifFalse:[ |
432 |
self hideHelp |
|
1536 | 433 |
]. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
434 |
|
2901
fed697afcef8
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
435 |
"Modified: / 22-03-2011 / 19:10:28 / cg" |
4082 | 436 |
"Modified: / 16-04-2018 / 12:20:33 / stefan" |
4110 | 437 |
"Modified: / 06-06-2018 / 17:19:26 / Claus Gittinger" |
1536 | 438 |
! |
439 |
||
440 |
showHelp:aHelpText for:view |
|
441 |
"show the help text for aView" |
|
442 |
||
3786 | 443 |
|wg applicationOrNil org p v device helpTextShown textLines |
3334 | 444 |
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight |
4119 | 445 |
showTime cursorView pos pointerPosition| |
1536 | 446 |
|
2781 | 447 |
"/ thisContext fullPrintAllOn:Transcript. |
2651 | 448 |
(wg := view windowGroup) notNil ifTrue:[ |
449 |
wg isInModalLoop ifTrue:[ |
|
450 |
wg isModal ifFalse:[ |
|
451 |
^ self |
|
452 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
453 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
454 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
455 |
|
3786 | 456 |
device := view graphicsDevice. |
4119 | 457 |
pointerPosition := device pointerPosition. |
458 |
||
3418 | 459 |
"/ mouse still over that view? |
4119 | 460 |
cursorView := device viewFromPoint:pointerPosition. |
3418 | 461 |
cursorView ~~ view ifTrue:[ |
462 |
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ]. |
|
463 |
^ self |
|
464 |
]. |
|
465 |
||
4082 | 466 |
(view == currentView and:[lastHelpText = aHelpText]) ifTrue:[ |
467 |
^ self |
|
1536 | 468 |
]. |
4119 | 469 |
|
470 |
pointerPositionAtShowTime := pointerPosition. |
|
3228 | 471 |
lastHelpWidget := view. |
1536 | 472 |
lastHelpText := aHelpText. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
473 |
helpTextShown := aHelpText. |
3257 | 474 |
"/ the text originator must already have generated CRs; |
4114 | 475 |
"/ no longer done here (otherwise, we could not generate tooltips with Windows filenames in it) |
3681 | 476 |
textLines := helpTextShown isStringCollection |
477 |
ifTrue:[helpTextShown] |
|
3767 | 478 |
ifFalse:[ |
479 |
helpTextShown isString |
|
480 |
ifTrue:[helpTextShown "withCRs" asCollectionOfLines asStringCollection] |
|
481 |
ifFalse:[nil]]. |
|
482 |
textLines notNil ifTrue:[ |
|
483 |
textLines size > (self class maxNumberOfLines) ifTrue:[ |
|
484 |
textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...' |
|
485 |
]. |
|
486 |
textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)]. |
|
487 |
helpTextShown := textLines asString. |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
488 |
]. |
3767 | 489 |
|
2780 | 490 |
(p := closeProcess) notNil ifTrue:[ |
491 |
closeProcess := nil. |
|
1536 | 492 |
p terminate. |
493 |
]. |
|
494 |
currentHelpView notNil ifTrue:[ |
|
495 |
self hideHelp |
|
496 |
]. |
|
497 |
||
3770 | 498 |
"/ Transcript showCR:helpTextShown storeString. |
3769 | 499 |
helpTextShown isEmptyOrNil ifTrue:[^ self]. |
500 |
||
1536 | 501 |
org := view originRelativeTo:nil. |
502 |
currentFrame := org extent:view extent. |
|
2848 | 503 |
org := org + (view extent // 2). |
1536 | 504 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
505 |
wg notNil ifTrue:[ applicationOrNil := wg application ]. |
3786 | 506 |
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
|
507 |
v perform:#controllingHelpListener: with:self ifNotUnderstood:[]. |
1536 | 508 |
|
2848 | 509 |
helpViewWidth := v width. |
510 |
helpViewHeight := v height. |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
511 |
|
4082 | 512 |
"https://expeccoalm.exept.de/D226383: keep the help window away from the pointer under any circumstances |
513 |
(especially when the window touches the bottom or the right edge of the screen). |
|
514 |
When the pointer is no longer in the current window, the help window is closed!!" |
|
515 |
pos := device pointerPosition. |
|
516 |
org := pos + (10@18). |
|
3786 | 517 |
monitorBounds := device monitorBoundsAt:org. |
3114 | 518 |
usableWidth := monitorBounds width - 2. |
3786 | 519 |
usableHeight := device usableHeightAt:org. |
3114 | 520 |
|
521 |
helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)]. |
|
3247 | 522 |
helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)]. |
3114 | 523 |
|
524 |
(org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[ |
|
4082 | 525 |
org x:(monitorBounds left + usableWidth - helpViewWidth). |
1536 | 526 |
]. |
3114 | 527 |
(org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[ |
4082 | 528 |
org y:(monitorBounds top + usableHeight - helpViewHeight). |
1536 | 529 |
]. |
4082 | 530 |
((org extent:v extent) containsPoint:pos) ifTrue:[ |
531 |
"pointer would be in the help window (see comment above). |
|
532 |
Help window is at the lower right edge. Move it to the left of the pointer" |
|
533 |
org x:(pos x - helpViewWidth - 20). |
|
534 |
]. |
|
1536 | 535 |
v origin:org. |
536 |
v realize. |
|
537 |
currentHelpView := v. |
|
2392 | 538 |
currentView := view. |
1536 | 539 |
|
3334 | 540 |
showTime := self showTime. |
4082 | 541 |
(showTime > 0) ifTrue:[ |
3959 | 542 |
p := |
543 |
[ |
|
1546 | 544 |
[ |
4082 | 545 |
Delay waitForSeconds:showTime. |
2392 | 546 |
[ |
2780 | 547 |
|v| |
548 |
(v := currentHelpView) notNil ifTrue:[ |
|
2392 | 549 |
currentHelpView := nil. |
2780 | 550 |
v destroy. |
2392 | 551 |
] |
552 |
] valueUninterruptably |
|
553 |
] ifCurtailed:[ |
|
3959 | 554 |
(p == closeProcess) ifTrue:[ closeProcess := nil ]. |
2392 | 555 |
]. |
556 |
] newProcess. |
|
3959 | 557 |
p priority:(Processor userSchedulingPriority + 1). |
558 |
closeProcess := p. |
|
559 |
p resume. |
|
2392 | 560 |
]. |
1536 | 561 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
562 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
3959 | 563 |
"Modified: / 06-06-2017 / 15:06:41 / cg" |
4082 | 564 |
"Modified (format): / 16-04-2018 / 17:29:10 / stefan" |
4119 | 565 |
"Modified: / 08-06-2018 / 10:28:32 / Claus Gittinger" |
1536 | 566 |
! |
567 |
||
568 |
stopHelpDisplayProcess |
|
569 |
|p| |
|
570 |
||
2680 | 571 |
(p := showProcess) notNil ifTrue:[ |
572 |
showProcess := nil. |
|
1536 | 573 |
p terminate. |
574 |
]. |
|
575 |
||
576 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
577 |
! ! |
|
578 |
||
579 |
!FlyByHelp class methodsFor:'documentation'! |
|
580 |
||
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
581 |
version |
3656 | 582 |
^ '$Header$' |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
583 |
! |
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
584 |
|
2754 | 585 |
version_CVS |
3656 | 586 |
^ '$Header$' |
1536 | 587 |
! ! |
3114 | 588 |