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