author | Claus Gittinger <cg@exept.de> |
Sat, 12 May 2018 14:23:45 +0200 | |
changeset 4088 | bbf9b58f99c8 |
parent 4082 | f2ffa50dcf0b |
child 4110 | 1a4cf666aafe |
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 |
2680 | 17 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
3255 | 18 |
classVariableNames:'MaxNumberOfLines MaxNumberOfColumns' |
1536 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Help' |
|
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:[ |
2925
352825e1163c
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
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. |
|
4040 | 199 |
text notNil ifTrue:[^ text]. |
1536 | 200 |
]. |
4048 | 201 |
(aModel respondsTo:#helpTextFor:) ifTrue:[ |
202 |
text := aModel helpTextFor:aView. |
|
2754 | 203 |
text notNil ifTrue:[^ text]. |
1536 | 204 |
]. |
2754 | 205 |
^ nil |
4040 | 206 |
|
207 |
"Modified: / 09-01-2018 / 17:35:26 / stefan" |
|
1536 | 208 |
! |
209 |
||
210 |
helpTextFromView:aView at:aPointOrNil |
|
211 |
"helper: ask aView for its helpText." |
|
212 |
||
2754 | 213 |
|text key app| |
1536 | 214 |
|
4048 | 215 |
(aPointOrNil notNil and:[aView respondsTo:#helpTextAt:]) ifTrue:[ |
216 |
text := aView helpTextAt:aPointOrNil. |
|
4040 | 217 |
text notNil ifTrue:[^ text]. |
1536 | 218 |
]. |
4048 | 219 |
(aView respondsTo:#helpText) ifTrue:[ |
220 |
text := aView helpText. |
|
2754 | 221 |
text notNil ifTrue:[^ text]. |
222 |
]. |
|
3804 | 223 |
"/ to be enabled in next release... |
224 |
"/ (aView superView notNil |
|
4048 | 225 |
"/ and:[aView superView respondsTo:#helpTextFor:]) ifTrue:[ |
226 |
"/ text := aView superView helpTextFor:aView. |
|
3804 | 227 |
"/ text notNil ifTrue:[^ text]. |
228 |
"/ ]. |
|
2754 | 229 |
(aView respondsTo:#helpKey) ifTrue:[ |
230 |
key := aView helpKey. |
|
231 |
key notNil ifTrue:[ |
|
232 |
app := aView application. |
|
233 |
app isNil ifTrue:[ |
|
3763 | 234 |
"/ special case for oldStyle Dialog subclasses. |
4048 | 235 |
aView topView helpSpec notNil ifTrue:[ |
236 |
text := aView topView helpSpec at:key ifAbsent:nil. |
|
3763 | 237 |
text notNil ifTrue:[ |
238 |
^ aView topView resources stringWithCRs:text. |
|
239 |
]. |
|
240 |
]. |
|
2754 | 241 |
app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ]. |
242 |
]. |
|
243 |
app notNil ifTrue:[ |
|
4048 | 244 |
^ app helpTextForKey:key |
2754 | 245 |
]. |
246 |
^ aView resources string:key |
|
1536 | 247 |
]. |
248 |
]. |
|
2754 | 249 |
^ nil. |
4040 | 250 |
|
251 |
"Modified: / 09-01-2018 / 17:38:42 / stefan" |
|
2392 | 252 |
! ! |
253 |
||
254 |
!FlyByHelp methodsFor:'private'! |
|
1536 | 255 |
|
256 |
hideIfPointerLeft:aView |
|
257 |
"hide help, if the pointer is not in aView" |
|
258 |
||
259 |
|whereOnScreen| |
|
260 |
||
261 |
currentFrame notNil ifTrue:[ |
|
262 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
263 |
||
264 |
(currentFrame notNil |
|
265 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
266 |
self hideHelp. |
|
267 |
]. |
|
268 |
]. |
|
269 |
||
4082 | 270 |
"Modified: / 28-05-1996 / 20:18:28 / cg" |
271 |
"Modified: / 16-04-2018 / 16:59:48 / stefan" |
|
1536 | 272 |
! |
273 |
||
274 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
275 |
"ask aView for helpText, passing x/y coordinates; |
|
276 |
start a timeout process to display this helpText after some delay; |
|
277 |
Normally used internally, but can also be used by widgets to force |
|
278 |
re-negotiation of the displayed helpText |
|
279 |
(for example in a menu, when the selection changes)" |
|
280 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
281 |
|text delayTime now| |
1536 | 282 |
|
283 |
(self interestedIn:aView) ifFalse:[ |
|
284 |
^ self |
|
285 |
]. |
|
286 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
287 |
now := Timestamp now. |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
288 |
|
2680 | 289 |
"/ 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
|
290 |
"/ 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
|
291 |
[ |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
292 |
Error handle:[:ex | |
3394 | 293 |
('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR. |
3675 | 294 |
Transcript showCR:'-------------------------'. |
3394 | 295 |
ex suspendedContext fullPrintAllOn:Transcript. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
296 |
"/ self halt. |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
297 |
] do:[ |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
298 |
text := self helpTextFor:aView at:aPointOrNil. |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
299 |
]. |
3656 | 300 |
] valueWithWatchDog:[ |
301 |
'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR. |
|
302 |
^ self |
|
303 |
] afterMilliseconds:(self flyByHelpTimeoutMillis). |
|
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
304 |
|
4082 | 305 |
(lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[ |
306 |
self toolTipFollowsMouse ifFalse:[ |
|
307 |
^ self |
|
2392 | 308 |
] |
1536 | 309 |
]. |
310 |
||
3767 | 311 |
((text size > 0) or:[text isString not]) ifTrue:[ |
2778 | 312 |
(showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[ |
1536 | 313 |
self stopHelpDisplayProcess. |
2392 | 314 |
showProcess := |
315 |
[ |
|
2680 | 316 |
Delay waitForSeconds:delayTime. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
317 |
[ |
3766 | 318 |
aView device notNil ifTrue:[ |
319 |
aView device anyButtonPressed ifFalse:[ |
|
320 |
showProcess := nil. |
|
321 |
self showHelp:text for:aView |
|
322 |
] |
|
323 |
]. |
|
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
324 |
] ensure:[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
325 |
showProcess := nil. |
2680 | 326 |
] |
2392 | 327 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 328 |
] ifFalse:[ |
329 |
self showHelp:text for:aView |
|
330 |
] |
|
1542 | 331 |
] ifFalse:[ |
332 |
self hideHelp |
|
1536 | 333 |
]. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
334 |
|
2901
fed697afcef8
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
335 |
"Modified: / 22-03-2011 / 19:10:28 / cg" |
4082 | 336 |
"Modified: / 16-04-2018 / 12:20:33 / stefan" |
1536 | 337 |
! ! |
338 |
||
2392 | 339 |
!FlyByHelp methodsFor:'queries'! |
340 |
||
2692 | 341 |
currentlyShownView |
342 |
^ currentHelpView |
|
343 |
! |
|
344 |
||
2392 | 345 |
toolTipFollowsMouse |
3675 | 346 |
"if true, the tooltip-window moves with the pointer |
347 |
so that it stays away from (does not cover) the mouse pointer" |
|
348 |
||
2392 | 349 |
^ false |
350 |
! ! |
|
351 |
||
1768 | 352 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 353 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
354 |
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
355 |
applicationOrNil notNil ifTrue:[ |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
356 |
^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
357 |
]. |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
358 |
^ ActiveHelpView for:helpText onDevice:aDevice. |
3656 | 359 |
|
360 |
" |
|
361 |
(ActiveHelpView for:'Hello' onDevice:Display) open |
|
362 |
" |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
363 |
! |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
364 |
|
1536 | 365 |
hideHelp |
366 |
"hide the help text" |
|
367 |
||
368 |
|p| |
|
369 |
||
3198 | 370 |
"/ lastHelpText := nil. |
1536 | 371 |
self stopHelpDisplayProcess. |
3258 | 372 |
lastHelpText := nil. |
1536 | 373 |
|
374 |
currentHelpView notNil ifTrue:[ |
|
375 |
[ |
|
2780 | 376 |
currentHelpView notNil ifTrue:[ |
377 |
currentHelpView destroy. |
|
378 |
currentHelpView := nil. |
|
379 |
currentView := nil. |
|
380 |
] |
|
1536 | 381 |
] valueUninterruptably |
382 |
]. |
|
383 |
currentFrame := nil. |
|
3198 | 384 |
(p := closeProcess) notNil ifTrue:[ |
385 |
closeProcess := nil. |
|
1536 | 386 |
p terminate. |
387 |
] |
|
388 |
||
4082 | 389 |
"Modified: / 28-06-1997 / 14:03:50 / cg" |
390 |
"Modified: / 16-04-2018 / 16:51:01 / stefan" |
|
1536 | 391 |
! |
392 |
||
393 |
showHelp:aHelpText for:view |
|
394 |
"show the help text for aView" |
|
395 |
||
3786 | 396 |
|wg applicationOrNil org p v device helpTextShown textLines |
3334 | 397 |
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight |
4082 | 398 |
showTime cursorView pos| |
1536 | 399 |
|
2781 | 400 |
"/ thisContext fullPrintAllOn:Transcript. |
2651 | 401 |
(wg := view windowGroup) notNil ifTrue:[ |
402 |
wg isInModalLoop ifTrue:[ |
|
403 |
wg isModal ifFalse:[ |
|
404 |
^ self |
|
405 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
406 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
407 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
408 |
|
3786 | 409 |
device := view graphicsDevice. |
410 |
||
3418 | 411 |
"/ mouse still over that view? |
3786 | 412 |
cursorView := device viewFromPoint:(device pointerPosition). |
3418 | 413 |
cursorView ~~ view ifTrue:[ |
414 |
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ]. |
|
415 |
^ self |
|
416 |
]. |
|
417 |
||
4082 | 418 |
(view == currentView and:[lastHelpText = aHelpText]) ifTrue:[ |
419 |
^ self |
|
1536 | 420 |
]. |
3228 | 421 |
lastHelpWidget := view. |
1536 | 422 |
lastHelpText := aHelpText. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
423 |
helpTextShown := aHelpText. |
3257 | 424 |
"/ the text originator must already have generated CRs; |
425 |
"/ no longer done here (otherwise, we could not generate tooltips with windows filenames in it) |
|
3681 | 426 |
textLines := helpTextShown isStringCollection |
427 |
ifTrue:[helpTextShown] |
|
3767 | 428 |
ifFalse:[ |
429 |
helpTextShown isString |
|
430 |
ifTrue:[helpTextShown "withCRs" asCollectionOfLines asStringCollection] |
|
431 |
ifFalse:[nil]]. |
|
432 |
textLines notNil ifTrue:[ |
|
433 |
textLines size > (self class maxNumberOfLines) ifTrue:[ |
|
434 |
textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...' |
|
435 |
]. |
|
436 |
textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)]. |
|
437 |
helpTextShown := textLines asString. |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
438 |
]. |
3767 | 439 |
|
2780 | 440 |
(p := closeProcess) notNil ifTrue:[ |
441 |
closeProcess := nil. |
|
1536 | 442 |
p terminate. |
443 |
]. |
|
444 |
currentHelpView notNil ifTrue:[ |
|
445 |
self hideHelp |
|
446 |
]. |
|
447 |
||
3770 | 448 |
"/ Transcript showCR:helpTextShown storeString. |
3769 | 449 |
helpTextShown isEmptyOrNil ifTrue:[^ self]. |
450 |
||
1536 | 451 |
org := view originRelativeTo:nil. |
452 |
currentFrame := org extent:view extent. |
|
2848 | 453 |
org := org + (view extent // 2). |
1536 | 454 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
455 |
wg notNil ifTrue:[ applicationOrNil := wg application ]. |
3786 | 456 |
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
|
457 |
v perform:#controllingHelpListener: with:self ifNotUnderstood:[]. |
1536 | 458 |
|
2848 | 459 |
helpViewWidth := v width. |
460 |
helpViewHeight := v height. |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
461 |
|
4082 | 462 |
"https://expeccoalm.exept.de/D226383: keep the help window away from the pointer under any circumstances |
463 |
(especially when the window touches the bottom or the right edge of the screen). |
|
464 |
When the pointer is no longer in the current window, the help window is closed!!" |
|
465 |
pos := device pointerPosition. |
|
466 |
org := pos + (10@18). |
|
3786 | 467 |
monitorBounds := device monitorBoundsAt:org. |
3114 | 468 |
usableWidth := monitorBounds width - 2. |
3786 | 469 |
usableHeight := device usableHeightAt:org. |
3114 | 470 |
|
471 |
helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)]. |
|
3247 | 472 |
helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)]. |
3114 | 473 |
|
474 |
(org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[ |
|
4082 | 475 |
org x:(monitorBounds left + usableWidth - helpViewWidth). |
1536 | 476 |
]. |
3114 | 477 |
(org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[ |
4082 | 478 |
org y:(monitorBounds top + usableHeight - helpViewHeight). |
1536 | 479 |
]. |
4082 | 480 |
((org extent:v extent) containsPoint:pos) ifTrue:[ |
481 |
"pointer would be in the help window (see comment above). |
|
482 |
Help window is at the lower right edge. Move it to the left of the pointer" |
|
483 |
org x:(pos x - helpViewWidth - 20). |
|
484 |
]. |
|
1536 | 485 |
v origin:org. |
486 |
v realize. |
|
487 |
currentHelpView := v. |
|
2392 | 488 |
currentView := view. |
1536 | 489 |
|
3334 | 490 |
showTime := self showTime. |
4082 | 491 |
(showTime > 0) ifTrue:[ |
3959 | 492 |
p := |
493 |
[ |
|
1546 | 494 |
[ |
4082 | 495 |
Delay waitForSeconds:showTime. |
2392 | 496 |
[ |
2780 | 497 |
|v| |
498 |
(v := currentHelpView) notNil ifTrue:[ |
|
2392 | 499 |
currentHelpView := nil. |
2780 | 500 |
v destroy. |
2392 | 501 |
] |
502 |
] valueUninterruptably |
|
503 |
] ifCurtailed:[ |
|
3959 | 504 |
(p == closeProcess) ifTrue:[ closeProcess := nil ]. |
2392 | 505 |
]. |
506 |
] newProcess. |
|
3959 | 507 |
p priority:(Processor userSchedulingPriority + 1). |
508 |
closeProcess := p. |
|
509 |
p resume. |
|
2392 | 510 |
]. |
1536 | 511 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
512 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
3959 | 513 |
"Modified: / 06-06-2017 / 15:06:41 / cg" |
4082 | 514 |
"Modified (format): / 16-04-2018 / 17:29:10 / stefan" |
1536 | 515 |
! |
516 |
||
517 |
stopHelpDisplayProcess |
|
518 |
|p| |
|
519 |
||
2680 | 520 |
(p := showProcess) notNil ifTrue:[ |
521 |
showProcess := nil. |
|
1536 | 522 |
p terminate. |
523 |
]. |
|
524 |
||
525 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
526 |
! ! |
|
527 |
||
528 |
!FlyByHelp class methodsFor:'documentation'! |
|
529 |
||
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
530 |
version |
3656 | 531 |
^ '$Header$' |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
532 |
! |
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
533 |
|
2754 | 534 |
version_CVS |
3656 | 535 |
^ '$Header$' |
1536 | 536 |
! ! |
3114 | 537 |