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