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