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