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