author | Claus Gittinger <cg@exept.de> |
Fri, 22 Feb 2019 11:18:16 +0100 | |
changeset 4233 | 7bc96946d912 |
parent 4231 | 5542e515b2d9 |
child 4237 | 4c0ddd2ce72e |
permissions | -rw-r--r-- |
4230 | 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 |
4119 | 19 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
20 |
classVariableNames:'MaxNumberOfLines MaxNumberOfColumns' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Help' |
|
1536 | 23 |
! |
24 |
||
4231 | 25 |
Query subclass:#HelpKeyInsteadOfHelpTextQuery |
26 |
instanceVariableNames:'' |
|
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:FlyByHelp |
|
30 |
! |
|
31 |
||
1802 | 32 |
!FlyByHelp class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
1893 | 46 |
! |
47 |
||
4055 | 48 |
documentation |
49 |
" |
|
50 |
an instance of me is used to provide tooltips |
|
51 |
(sigh: smalltalk was ahead of its time in the early 90's: |
|
52 |
initially called 'activeHelp', then renamed to 'flyByHelp' |
|
53 |
and now commonly known as tooltip). |
|
54 |
||
55 |
I will watch the mouse movements via an event hook, and determine |
|
56 |
where the mouse pointer is. Then ask the underlying view about its |
|
57 |
helpText and display it in a little floating popup view. |
|
58 |
||
59 |
The hool is installed via: |
|
60 |
FlyByHelp start |
|
61 |
and possibly deactivated/uninstalled via: |
|
62 |
FlyByHelp stop |
|
63 |
||
64 |
There can be only one FlyByHelp at any time - the start/stop methods |
|
65 |
assure that. |
|
66 |
" |
|
67 |
! |
|
68 |
||
1893 | 69 |
examples |
70 |
" |
|
3220 | 71 |
UserPreferences current toolTipShapeStyle:nil |
72 |
UserPreferences current toolTipShapeStyle:#cartoon |
|
73 |
||
1893 | 74 |
FlyByHelp isActive |
75 |
||
76 |
FlyByHelp stop |
|
77 |
FlyByHelp start |
|
78 |
" |
|
1802 | 79 |
! ! |
1536 | 80 |
|
2692 | 81 |
!FlyByHelp class methodsFor:'accessing'! |
82 |
||
83 |
currentlyShownView |
|
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
84 |
TheOneAndOnlyHelpListener isNil ifTrue:[^ nil]. |
2692 | 85 |
^ TheOneAndOnlyHelpListener currentlyShownView |
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
86 |
|
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
87 |
"Modified: / 09-06-2010 / 16:35:48 / cg" |
3255 | 88 |
! |
89 |
||
4231 | 90 |
helpKeyInsteadOfHelpTextQuery |
91 |
^ HelpKeyInsteadOfHelpTextQuery |
|
92 |
||
93 |
"Created: / 22-02-2019 / 09:38:18 / Claus Gittinger" |
|
94 |
! |
|
95 |
||
3255 | 96 |
maxNumberOfColumns |
97 |
^ MaxNumberOfColumns ? 200 |
|
98 |
! |
|
99 |
||
100 |
maxNumberOfLines |
|
101 |
^ MaxNumberOfLines ? 40 |
|
2692 | 102 |
! ! |
103 |
||
2684 | 104 |
!FlyByHelp methodsFor:'defaults'! |
105 |
||
106 |
flyByHelpTimeoutMillis |
|
107 |
"abort flyby help text generation, if no text can be generated within that |
|
108 |
time delta. This is used to abort long-lasting parsing/scanning/analysis in |
|
109 |
large methods when the mouse is moved over some syntactic constructs, and |
|
110 |
it takes too long to parse... |
|
111 |
The returned time is given in ms" |
|
112 |
||
113 |
^ 300 |
|
114 |
! ! |
|
115 |
||
4233 | 116 |
!FlyByHelp methodsFor:'developer menu'! |
117 |
||
118 |
openDeveloperMenuFor:aView at:aPoint |
|
119 |
"with CTRL+SHIFT, this menu appears" |
|
120 |
||
121 |
|app helpText helpKey| |
|
122 |
||
123 |
app := aView topView application. |
|
124 |
app enqueueDelayedAction:[ |
|
125 |
|editor m canDefineTranslationForLabel canDefineTranslationForHelpText| |
|
126 |
||
127 |
m := Menu new. |
|
128 |
m addItem:(MenuItem |
|
129 |
label: 'Edit Resources' |
|
130 |
itemValue:[ |
|
131 |
app enqueueDelayedAction:[ |
|
132 |
app withWaitCursorDo:[ |
|
133 |
editor := Tools::InternationalLanguageTranslationEditor |
|
134 |
openOnPackage:((aView topView application ? aView) class package). |
|
135 |
editor selectOrAddKey:(lastHelpText storeString withoutCRs). |
|
136 |
Transcript showCR:'help text is: %1' with:lastHelpText storeString withoutCRs. |
|
137 |
||
138 |
]. |
|
139 |
]. |
|
140 |
]). |
|
141 |
m addItem:(MenuItem |
|
142 |
label: 'Browse Resources' |
|
143 |
itemValue:[ |
|
144 |
app enqueueDelayedAction:[ |
|
145 |
app withWaitCursorDo:[ |
|
146 |
FileBrowser default |
|
147 |
openOn:(app class projectDefinitionClass |
|
148 |
packageDirectory / 'resources'). |
|
149 |
]. |
|
150 |
]. |
|
151 |
]). |
|
152 |
||
153 |
canDefineTranslationForLabel := |
|
154 |
[ |
|
155 |
(aView isKindOf:Label) or:[aView respondsTo:#label] |
|
156 |
]. |
|
157 |
||
158 |
canDefineTranslationForHelpText := |
|
159 |
[ |
|
160 |
|ok| |
|
161 |
||
162 |
ok := lastHelpText notEmptyOrNil. |
|
163 |
ok := ok or:[ (helpText := aView helpTextAt:aPoint) notEmptyOrNil]. |
|
164 |
ok := ok or:[ (helpText := aView helpText) notEmptyOrNil]. |
|
165 |
ok := ok or:[ (helpKey := aView helpKey) notNil]. |
|
166 |
ok := ok or:[ (helpText := app helpTextFor:aView) notEmptyOrNil ]. |
|
167 |
ok |
|
168 |
]. |
|
169 |
||
170 |
m addItem:(MenuItem |
|
171 |
label: 'Define Translation for Label...' |
|
172 |
itemValue:[ |
|
173 |
|package key | |
|
174 |
||
175 |
key := aView label asString string. |
|
176 |
package := app class package. |
|
177 |
ResourcePack defineResourceFor:key package:package. |
|
178 |
] |
|
179 |
enabled:canDefineTranslationForLabel). |
|
180 |
m addItem:(MenuItem |
|
181 |
label: 'Define Translation for Helptext...' |
|
182 |
itemValue:[ |
|
183 |
|package key | |
|
184 |
||
185 |
key := (lastHelpText ? helpText ? helpKey) asString string. |
|
186 |
package := app class package. |
|
187 |
ResourcePack defineResourceFor:key package:package. |
|
188 |
] |
|
189 |
enabled:canDefineTranslationForHelpText). |
|
190 |
||
191 |
m addSeparator. |
|
192 |
m addItem:(MenuItem |
|
193 |
label: 'Browse Application' |
|
194 |
itemValue:[ SystemBrowser default openInClass:aView application class]). |
|
195 |
||
196 |
m addItem:(MenuItem |
|
197 |
label: 'UI Painter' |
|
198 |
itemValue:[ UIPainter openOnClass:aView application class andSelector:#windowSpec]). |
|
199 |
||
200 |
aView application ~~ app ifTrue:[ |
|
201 |
m addSeparator. |
|
202 |
m addItem:(MenuItem |
|
203 |
label: 'Browse Top Application' |
|
204 |
itemValue:[ SystemBrowser default openInClass:app class]). |
|
205 |
||
206 |
m addItem:(MenuItem |
|
207 |
label: 'UI Painter on Top Application' |
|
208 |
itemValue:[ UIPainter openOnClass:app class andSelector:#windowSpec]). |
|
209 |
]. |
|
210 |
||
211 |
m showAtPointer. |
|
212 |
]. |
|
213 |
||
214 |
"Created: / 22-02-2019 / 09:32:35 / Claus Gittinger" |
|
215 |
! ! |
|
216 |
||
2392 | 217 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 218 |
|
2474 | 219 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 220 |
aView == currentHelpView ifTrue:[ |
221 |
"/ the help-bubble itself |
|
222 |
^ false |
|
223 |
]. |
|
224 |
||
4055 | 225 |
"/ don't start tooltip, if this view is not active. |
226 |
"/ The following line does not work, because motion events are reported for the current focus-view, |
|
3321 | 227 |
"/ which is always active. Must check after we have determined the view under the pointer |
3675 | 228 |
"/ aView topView isActive ifFalse:[^ false]. |
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
229 |
|
2474 | 230 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 231 |
! |
232 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
233 |
buttonPress:button x:x y:y view:aView |
3198 | 234 |
|prevView| |
235 |
||
236 |
"/ hideHelp nils the currentView |
|
237 |
"/ we restore it, so the tooltip is not shown again for this view |
|
238 |
"/ until the mouse really leaves the view |
|
239 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
240 |
prevView := currentView. |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
241 |
self hideHelp. |
3198 | 242 |
currentView := prevView. |
243 |
||
244 |
^ false |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
245 |
|
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
246 |
"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
|
247 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
248 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
249 |
keyPress:key x:x y:y view:aView |
4226 | 250 |
<resource: #keyboard (#Escape #Control #Shift)> |
3216 | 251 |
|
4228 | 252 |
|prevView text| |
3198 | 253 |
|
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
254 |
currentHelpView notNil ifTrue:[ |
4230 | 255 |
key == $§ ifTrue:[ |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
256 |
"/ generate a line suitable for the resources file (a null translation) |
3216 | 257 |
"/ into the clipboard; makes it easy to add missing translations to a .rs file, |
4082 | 258 |
"/ by pressing paragraph whenever you see an untranslated helptext |
4228 | 259 |
text := (lastHelpText storeString withoutCRs, ' ' , lastHelpText storeString withoutCRs). |
260 |
aView setClipboardText:text. |
|
2612 | 261 |
self hideHelp. |
4230 | 262 |
^ false |
2612 | 263 |
]. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
264 |
key == #Escape ifTrue:[ |
3198 | 265 |
prevView := currentView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
266 |
self hideHelp. |
3198 | 267 |
currentView := prevView. |
4230 | 268 |
^ false |
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
269 |
]. |
4228 | 270 |
(#(#'Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[ |
271 |
aView device ctrlDown ifTrue:[ |
|
4230 | 272 |
self hideHelp. |
4231 | 273 |
self openDeveloperMenuFor:aView at:x@y |
4230 | 274 |
]. |
275 |
^ false |
|
4228 | 276 |
]. |
277 |
||
278 |
(#(#'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
4226 | 279 |
"/ reopen showing the key |
280 |
self initiateHelpFor:aView at:(x@y) now:true. |
|
4230 | 281 |
^ false |
4226 | 282 |
]. |
283 |
||
284 |
(#('Shift' #'Shift_L' #'Shift_R' #'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
3216 | 285 |
"/ do not close on those... |
286 |
^ false |
|
287 |
]. |
|
4226 | 288 |
]. |
3198 | 289 |
|
290 |
"/ hideHelp nils the currentView |
|
291 |
"/ we restore it, so the tooltip is not shown again for this view |
|
292 |
"/ until the mouse really leaves the view |
|
293 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
294 |
prevView := currentView. |
|
295 |
self hideHelpIgnoringErrors. |
|
296 |
currentView := prevView. |
|
297 |
||
298 |
^ false |
|
299 |
"/ ^ 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
|
300 |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
301 |
"Modified (format): / 25-12-2011 / 10:25:23 / cg" |
4082 | 302 |
"Modified (format): / 16-04-2018 / 16:53:15 / stefan" |
4231 | 303 |
"Modified: / 22-02-2019 / 09:32:28 / Claus Gittinger" |
4226 | 304 |
! |
305 |
||
306 |
keyRelease:key x:x y:y view:aView |
|
307 |
<resource: #keyboard (#Control)> |
|
308 |
||
309 |
currentHelpView notNil ifTrue:[ |
|
310 |
(#(#'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
311 |
"/ reopen showing the text |
|
312 |
self initiateHelpFor:aView at:(x@y) now:true. |
|
313 |
^ true |
|
314 |
]. |
|
315 |
(#('Shift' #'Shift_L' #'Shift_R' #'Control' #'Control_L' #'Control_R') includes:key) ifTrue:[ |
|
316 |
"/ do not close on those... |
|
317 |
^ false |
|
318 |
]. |
|
319 |
]. |
|
320 |
^ super keyRelease:key x:x y:y view:aView |
|
321 |
||
322 |
"Created: / 20-02-2019 / 11:26:19 / Claus Gittinger" |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
323 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
324 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
325 |
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
|
326 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
327 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
328 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
329 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
330 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
331 |
|
1540 | 332 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
333 |
aView == currentHelpView ifTrue:[^ true]. |
3198 | 334 |
|
335 |
"/ clear the do-not-show-in-this-view mode (see keyPress) |
|
336 |
"/ (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil]. |
|
337 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
338 |
^ super pointerLeave:state view:aView |
1540 | 339 |
! ! |
340 |
||
2392 | 341 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 342 |
|
343 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
344 |
"helper: ask aModel for its helpText." |
|
345 |
||
346 |
|text| |
|
347 |
||
4048 | 348 |
(aPointOrNil notNil and:[aModel respondsTo:#helpTextFor:at:]) ifTrue:[ |
349 |
text := aModel helpTextFor:aView at:aPointOrNil. |
|
4121 | 350 |
text notNil ifTrue:[ |
351 |
"/ Transcript showCR:aModel. |
|
352 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
353 |
^ text |
|
354 |
]. |
|
1536 | 355 |
]. |
4048 | 356 |
(aModel respondsTo:#helpTextFor:) ifTrue:[ |
357 |
text := aModel helpTextFor:aView. |
|
4121 | 358 |
text notNil ifTrue:[ |
359 |
"/ Transcript showCR:aModel. |
|
360 |
"/ Transcript showCR:'via model-text'; showCR:text. |
|
361 |
^ text |
|
362 |
]. |
|
1536 | 363 |
]. |
2754 | 364 |
^ nil |
4040 | 365 |
|
366 |
"Modified: / 09-01-2018 / 17:35:26 / stefan" |
|
4121 | 367 |
"Modified: / 11-06-2018 / 09:53:40 / Claus Gittinger" |
1536 | 368 |
! |
369 |
||
370 |
helpTextFromView:aView at:aPointOrNil |
|
371 |
"helper: ask aView for its helpText." |
|
372 |
||
2754 | 373 |
|text key app| |
1536 | 374 |
|
4121 | 375 |
"/ is there any view which does not understand helpTextAt: ??? |
4048 | 376 |
(aPointOrNil notNil and:[aView respondsTo:#helpTextAt:]) ifTrue:[ |
377 |
text := aView helpTextAt:aPointOrNil. |
|
4121 | 378 |
text notNil ifTrue:[ |
379 |
"/ Transcript showCR:'via helpTextAt:'; showCR:text. |
|
380 |
^ text |
|
381 |
]. |
|
1536 | 382 |
]. |
4121 | 383 |
"/ is there any view which does not understand helpText ??? |
4048 | 384 |
(aView respondsTo:#helpText) ifTrue:[ |
385 |
text := aView helpText. |
|
4121 | 386 |
text notNil ifTrue:[ |
387 |
"/ Transcript showCR:'via helpText'; showCR:text. |
|
4220 | 388 |
^ text value |
4121 | 389 |
]. |
2754 | 390 |
]. |
3804 | 391 |
"/ to be enabled in next release... |
392 |
"/ (aView superView notNil |
|
4048 | 393 |
"/ and:[aView superView respondsTo:#helpTextFor:]) ifTrue:[ |
394 |
"/ text := aView superView helpTextFor:aView. |
|
3804 | 395 |
"/ text notNil ifTrue:[^ text]. |
396 |
"/ ]. |
|
4121 | 397 |
|
398 |
"/ is there any view which does not understand helpKey ??? |
|
2754 | 399 |
(aView respondsTo:#helpKey) ifTrue:[ |
400 |
key := aView helpKey. |
|
401 |
key notNil ifTrue:[ |
|
402 |
app := aView application. |
|
403 |
app isNil ifTrue:[ |
|
4175 | 404 |
|topView topViewsHelpSpec| |
405 |
||
3763 | 406 |
"/ special case for oldStyle Dialog subclasses. |
4175 | 407 |
topView := aView topView. |
408 |
(topViewsHelpSpec := topView helpSpec) notNil ifTrue:[ |
|
409 |
text := topViewsHelpSpec at:key ifAbsent:nil. |
|
3763 | 410 |
text notNil ifTrue:[ |
4121 | 411 |
"/ Transcript showCR:'via topViewspec+helpKey'; showCR:text. |
4175 | 412 |
^ topView resources stringWithCRs:text. |
3763 | 413 |
]. |
414 |
]. |
|
2754 | 415 |
app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ]. |
416 |
]. |
|
417 |
app notNil ifTrue:[ |
|
4121 | 418 |
text := app helpTextForKey:key. |
419 |
true "text notNil" ifTrue:[ |
|
420 |
"/ Transcript showCR:'via helpKey+helpTextForKey:'; showCR:text. |
|
421 |
^ text |
|
422 |
]. |
|
2754 | 423 |
]. |
4121 | 424 |
text := aView resources string:key. |
425 |
true "(text notNil and:[text ~= key])" ifTrue:[ |
|
426 |
"/ Transcript showCR:'via helpKey'; showCR:text. |
|
4110 | 427 |
^ text |
428 |
] |
|
1536 | 429 |
]. |
430 |
]. |
|
2754 | 431 |
^ nil. |
4040 | 432 |
|
433 |
"Modified: / 09-01-2018 / 17:38:42 / stefan" |
|
4111 | 434 |
"Modified (format): / 07-06-2018 / 09:51:41 / sr" |
4220 | 435 |
"Modified: / 07-02-2019 / 19:18:39 / Claus Gittinger" |
2392 | 436 |
! ! |
437 |
||
4119 | 438 |
!FlyByHelp methodsFor:'queries'! |
439 |
||
440 |
currentlyShownView |
|
441 |
^ currentHelpView |
|
442 |
! |
|
443 |
||
444 |
toolTipFollowsMouse |
|
445 |
"if true, the tooltip-window moves with the pointer |
|
446 |
so that it stays away from (does not cover) the mouse pointer" |
|
447 |
||
448 |
^ false |
|
449 |
||
450 |
"Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger" |
|
451 |
! ! |
|
452 |
||
453 |
!FlyByHelp methodsFor:'show & hide help'! |
|
454 |
||
455 |
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice |
|
456 |
applicationOrNil notNil ifTrue:[ |
|
457 |
^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice |
|
458 |
]. |
|
459 |
^ ActiveHelpView for:helpText onDevice:aDevice. |
|
460 |
||
461 |
" |
|
462 |
(ActiveHelpView for:'Hello' onDevice:Display) open |
|
463 |
" |
|
464 |
! |
|
465 |
||
466 |
hideHelp |
|
467 |
"hide the help text" |
|
468 |
||
469 |
|p| |
|
470 |
||
471 |
"/ lastHelpText := nil. |
|
472 |
self stopHelpDisplayProcess. |
|
473 |
lastHelpText := nil. |
|
474 |
||
475 |
currentHelpView notNil ifTrue:[ |
|
476 |
[ |
|
477 |
currentHelpView notNil ifTrue:[ |
|
478 |
currentHelpView destroy. |
|
479 |
currentHelpView := nil. |
|
480 |
currentView := nil. |
|
481 |
] |
|
482 |
] valueUninterruptably |
|
483 |
]. |
|
484 |
currentFrame := nil. |
|
485 |
(p := closeProcess) notNil ifTrue:[ |
|
486 |
closeProcess := nil. |
|
487 |
p terminate. |
|
488 |
] |
|
489 |
||
490 |
"Modified: / 28-06-1997 / 14:03:50 / cg" |
|
491 |
"Modified: / 16-04-2018 / 16:51:01 / stefan" |
|
492 |
! |
|
1536 | 493 |
|
494 |
hideIfPointerLeft:aView |
|
495 |
"hide help, if the pointer is not in aView" |
|
496 |
||
4119 | 497 |
|helpFrame whereOnScreen| |
1536 | 498 |
|
4119 | 499 |
(helpFrame := currentFrame) notNil ifTrue:[ |
1536 | 500 |
whereOnScreen := aView graphicsDevice pointerPosition. |
501 |
||
4119 | 502 |
((helpFrame insetBy:1@1) containsPoint:whereOnScreen) ifFalse:[ |
1536 | 503 |
self hideHelp. |
4119 | 504 |
] ifTrue:[ |
505 |
pointerPositionAtShowTime notNil ifTrue:[ |
|
506 |
(whereOnScreen dist:pointerPositionAtShowTime) > 10 ifTrue:[ |
|
507 |
self hideHelp. |
|
508 |
]. |
|
509 |
]. |
|
510 |
]. |
|
1536 | 511 |
]. |
512 |
||
4082 | 513 |
"Modified: / 28-05-1996 / 20:18:28 / cg" |
514 |
"Modified: / 16-04-2018 / 16:59:48 / stefan" |
|
4119 | 515 |
"Modified: / 08-06-2018 / 10:30:04 / Claus Gittinger" |
1536 | 516 |
! |
517 |
||
518 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
519 |
"ask aView for helpText, passing x/y coordinates; |
|
520 |
start a timeout process to display this helpText after some delay; |
|
521 |
Normally used internally, but can also be used by widgets to force |
|
522 |
re-negotiation of the displayed helpText |
|
523 |
(for example in a menu, when the selection changes)" |
|
524 |
||
4110 | 525 |
|text delayTime| |
1536 | 526 |
|
527 |
(self interestedIn:aView) ifFalse:[ |
|
528 |
^ self |
|
529 |
]. |
|
530 |
||
2680 | 531 |
"/ 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
|
532 |
"/ 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
|
533 |
[ |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
534 |
Error handle:[:ex | |
3394 | 535 |
('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR. |
3675 | 536 |
Transcript showCR:'-------------------------'. |
3394 | 537 |
ex suspendedContext fullPrintAllOn:Transcript. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
538 |
"/ self halt. |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
539 |
] do:[ |
4231 | 540 |
HelpKeyInsteadOfHelpTextQuery answer:(aView device ctrlDown) do:[ |
541 |
text := self helpTextFor:aView at:aPointOrNil. |
|
542 |
]. |
|
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
543 |
]. |
3656 | 544 |
] valueWithWatchDog:[ |
545 |
'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR. |
|
546 |
^ self |
|
547 |
] afterMilliseconds:(self flyByHelpTimeoutMillis). |
|
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
548 |
|
4110 | 549 |
false ifTrue:[ |
550 |
(text notNil and:[text isEmpty]) ifTrue:[ |
|
551 |
Logger warning:('empty help from: ',aView class printString) |
|
552 |
] ifFalse:[ |
|
553 |
text isEmptyOrNil ifTrue:[ |
|
554 |
Logger warning:('no help from: ',aView class printString) |
|
555 |
]. |
|
556 |
]. |
|
557 |
]. |
|
558 |
||
4082 | 559 |
(lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[ |
560 |
self toolTipFollowsMouse ifFalse:[ |
|
561 |
^ self |
|
2392 | 562 |
] |
1536 | 563 |
]. |
564 |
||
4110 | 565 |
((text size > 0) or:[text notNil and:[text isString not]]) ifTrue:[ |
2778 | 566 |
(showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[ |
1536 | 567 |
self stopHelpDisplayProcess. |
2392 | 568 |
showProcess := |
569 |
[ |
|
2680 | 570 |
Delay waitForSeconds:delayTime. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
571 |
[ |
3766 | 572 |
aView device notNil ifTrue:[ |
573 |
aView device anyButtonPressed ifFalse:[ |
|
574 |
showProcess := nil. |
|
575 |
self showHelp:text for:aView |
|
576 |
] |
|
577 |
]. |
|
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
578 |
] ensure:[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
579 |
showProcess := nil. |
2680 | 580 |
] |
2392 | 581 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 582 |
] ifFalse:[ |
583 |
self showHelp:text for:aView |
|
584 |
] |
|
1542 | 585 |
] ifFalse:[ |
586 |
self hideHelp |
|
1536 | 587 |
]. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
588 |
|
2901
fed697afcef8
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
589 |
"Modified: / 22-03-2011 / 19:10:28 / cg" |
4082 | 590 |
"Modified: / 16-04-2018 / 12:20:33 / stefan" |
4231 | 591 |
"Modified: / 22-02-2019 / 09:42:56 / Claus Gittinger" |
1536 | 592 |
! |
593 |
||
594 |
showHelp:aHelpText for:view |
|
595 |
"show the help text for aView" |
|
596 |
||
3786 | 597 |
|wg applicationOrNil org p v device helpTextShown textLines |
3334 | 598 |
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight |
4119 | 599 |
showTime cursorView pos pointerPosition| |
1536 | 600 |
|
2781 | 601 |
"/ thisContext fullPrintAllOn:Transcript. |
2651 | 602 |
(wg := view windowGroup) notNil ifTrue:[ |
603 |
wg isInModalLoop ifTrue:[ |
|
604 |
wg isModal ifFalse:[ |
|
605 |
^ self |
|
606 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
607 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
608 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
609 |
|
3786 | 610 |
device := view graphicsDevice. |
4119 | 611 |
pointerPosition := device pointerPosition. |
612 |
||
3418 | 613 |
"/ mouse still over that view? |
4119 | 614 |
cursorView := device viewFromPoint:pointerPosition. |
3418 | 615 |
cursorView ~~ view ifTrue:[ |
616 |
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ]. |
|
617 |
^ self |
|
618 |
]. |
|
619 |
||
4082 | 620 |
(view == currentView and:[lastHelpText = aHelpText]) ifTrue:[ |
621 |
^ self |
|
1536 | 622 |
]. |
4119 | 623 |
|
624 |
pointerPositionAtShowTime := pointerPosition. |
|
3228 | 625 |
lastHelpWidget := view. |
1536 | 626 |
lastHelpText := aHelpText. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
627 |
helpTextShown := aHelpText. |
4129 | 628 |
|
3257 | 629 |
"/ the text originator must already have generated CRs; |
4114 | 630 |
"/ no longer done here (otherwise, we could not generate tooltips with Windows filenames in it) |
3681 | 631 |
textLines := helpTextShown isStringCollection |
632 |
ifTrue:[helpTextShown] |
|
3767 | 633 |
ifFalse:[ |
634 |
helpTextShown isString |
|
4129 | 635 |
ifTrue:[helpTextShown asCollectionOfLines asStringCollection] |
3767 | 636 |
ifFalse:[nil]]. |
637 |
textLines notNil ifTrue:[ |
|
638 |
textLines size > (self class maxNumberOfLines) ifTrue:[ |
|
639 |
textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...' |
|
640 |
]. |
|
641 |
textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)]. |
|
642 |
helpTextShown := textLines asString. |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
643 |
]. |
3767 | 644 |
|
2780 | 645 |
(p := closeProcess) notNil ifTrue:[ |
646 |
closeProcess := nil. |
|
1536 | 647 |
p terminate. |
648 |
]. |
|
649 |
currentHelpView notNil ifTrue:[ |
|
650 |
self hideHelp |
|
651 |
]. |
|
652 |
||
3770 | 653 |
"/ Transcript showCR:helpTextShown storeString. |
3769 | 654 |
helpTextShown isEmptyOrNil ifTrue:[^ self]. |
655 |
||
1536 | 656 |
org := view originRelativeTo:nil. |
657 |
currentFrame := org extent:view extent. |
|
2848 | 658 |
org := org + (view extent // 2). |
1536 | 659 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
660 |
wg notNil ifTrue:[ applicationOrNil := wg application ]. |
3786 | 661 |
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
|
662 |
v perform:#controllingHelpListener: with:self ifNotUnderstood:[]. |
1536 | 663 |
|
2848 | 664 |
helpViewWidth := v width. |
665 |
helpViewHeight := v height. |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
666 |
|
4082 | 667 |
"https://expeccoalm.exept.de/D226383: keep the help window away from the pointer under any circumstances |
668 |
(especially when the window touches the bottom or the right edge of the screen). |
|
669 |
When the pointer is no longer in the current window, the help window is closed!!" |
|
670 |
pos := device pointerPosition. |
|
671 |
org := pos + (10@18). |
|
3786 | 672 |
monitorBounds := device monitorBoundsAt:org. |
3114 | 673 |
usableWidth := monitorBounds width - 2. |
3786 | 674 |
usableHeight := device usableHeightAt:org. |
3114 | 675 |
|
676 |
helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)]. |
|
3247 | 677 |
helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)]. |
3114 | 678 |
|
679 |
(org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[ |
|
4082 | 680 |
org x:(monitorBounds left + usableWidth - helpViewWidth). |
1536 | 681 |
]. |
3114 | 682 |
(org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[ |
4082 | 683 |
org y:(monitorBounds top + usableHeight - helpViewHeight). |
1536 | 684 |
]. |
4082 | 685 |
((org extent:v extent) containsPoint:pos) ifTrue:[ |
686 |
"pointer would be in the help window (see comment above). |
|
687 |
Help window is at the lower right edge. Move it to the left of the pointer" |
|
688 |
org x:(pos x - helpViewWidth - 20). |
|
689 |
]. |
|
1536 | 690 |
v origin:org. |
691 |
v realize. |
|
692 |
currentHelpView := v. |
|
2392 | 693 |
currentView := view. |
1536 | 694 |
|
3334 | 695 |
showTime := self showTime. |
4082 | 696 |
(showTime > 0) ifTrue:[ |
3959 | 697 |
p := |
698 |
[ |
|
1546 | 699 |
[ |
4082 | 700 |
Delay waitForSeconds:showTime. |
2392 | 701 |
[ |
2780 | 702 |
|v| |
703 |
(v := currentHelpView) notNil ifTrue:[ |
|
2392 | 704 |
currentHelpView := nil. |
2780 | 705 |
v destroy. |
2392 | 706 |
] |
707 |
] valueUninterruptably |
|
708 |
] ifCurtailed:[ |
|
3959 | 709 |
(p == closeProcess) ifTrue:[ closeProcess := nil ]. |
2392 | 710 |
]. |
711 |
] newProcess. |
|
3959 | 712 |
p priority:(Processor userSchedulingPriority + 1). |
713 |
closeProcess := p. |
|
714 |
p resume. |
|
2392 | 715 |
]. |
1536 | 716 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
717 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
3959 | 718 |
"Modified: / 06-06-2017 / 15:06:41 / cg" |
4082 | 719 |
"Modified (format): / 16-04-2018 / 17:29:10 / stefan" |
4119 | 720 |
"Modified: / 08-06-2018 / 10:28:32 / Claus Gittinger" |
4129 | 721 |
"Modified (format): / 14-06-2018 / 08:29:43 / Claus Gittinger" |
1536 | 722 |
! |
723 |
||
724 |
stopHelpDisplayProcess |
|
725 |
|p| |
|
726 |
||
2680 | 727 |
(p := showProcess) notNil ifTrue:[ |
728 |
showProcess := nil. |
|
1536 | 729 |
p terminate. |
730 |
]. |
|
731 |
||
732 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
733 |
! ! |
|
734 |
||
4231 | 735 |
!FlyByHelp::HelpKeyInsteadOfHelpTextQuery class methodsFor:'documentation'! |
736 |
||
737 |
documentation |
|
738 |
" |
|
739 |
kludge to force application to return the helpKey instead of the |
|
740 |
help text. |
|
741 |
Answering true will tell the ApplicationModel to return the key. |
|
742 |
(see AppModel >> helpTextForKey:) |
|
743 |
||
744 |
[author:] |
|
745 |
Claus Gittinger |
|
746 |
||
747 |
[instance variables:] |
|
748 |
||
749 |
[class variables:] |
|
750 |
||
751 |
[see also:] |
|
752 |
||
753 |
" |
|
754 |
! ! |
|
755 |
||
756 |
!FlyByHelp::HelpKeyInsteadOfHelpTextQuery methodsFor:'defaults'! |
|
757 |
||
758 |
defaultResumeValue |
|
759 |
^ false |
|
760 |
||
761 |
"Created: / 22-02-2019 / 09:48:28 / Claus Gittinger" |
|
762 |
! ! |
|
763 |
||
1536 | 764 |
!FlyByHelp class methodsFor:'documentation'! |
765 |
||
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
766 |
version |
3656 | 767 |
^ '$Header$' |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
768 |
! |
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
769 |
|
2754 | 770 |
version_CVS |
3656 | 771 |
^ '$Header$' |
1536 | 772 |
! ! |
3114 | 773 |