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