author | Claus Gittinger <cg@exept.de> |
Wed, 13 May 2009 13:23:32 +0200 | |
changeset 2675 | a68038b7c4c3 |
parent 2651 | 7275384a60c7 |
child 2679 | 552847065fb3 |
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 |
||
14 |
ActiveHelp subclass:#FlyByHelp |
|
15 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
|
1892 | 16 |
classVariableNames:'' |
1536 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-Help' |
|
19 |
! |
|
20 |
||
1802 | 21 |
!FlyByHelp class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
1893 | 35 |
! |
36 |
||
37 |
examples |
|
38 |
" |
|
39 |
FlyByHelp isActive |
|
40 |
||
41 |
FlyByHelp stop |
|
42 |
FlyByHelp start |
|
43 |
" |
|
1802 | 44 |
! ! |
1536 | 45 |
|
46 |
!FlyByHelp class methodsFor:'initialization'! |
|
47 |
||
48 |
initialize |
|
49 |
"set default delay & help-display times" |
|
50 |
||
1657 | 51 |
ShowTime := 10. |
52 |
DelayTime := 0.4. |
|
1536 | 53 |
|
54 |
" |
|
55 |
FlyByHelp initialize |
|
56 |
" |
|
57 |
||
58 |
"Modified: 27.4.1996 / 15:07:27 / cg" |
|
59 |
! ! |
|
60 |
||
2392 | 61 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 62 |
|
2474 | 63 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 64 |
aView == currentHelpView ifTrue:[ |
65 |
"/ the help-bubble itself |
|
66 |
^ false |
|
67 |
]. |
|
68 |
||
2518 | 69 |
"/ don't start tooltip, if this view is not active |
70 |
"/ aView topView isActive ifFalse:[^ false]. |
|
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
71 |
|
2474 | 72 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 73 |
! |
74 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
75 |
buttonPress:button x:x y:y view:aView |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
76 |
aView == currentHelpView ifTrue:[ |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
77 |
self hideHelp. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
78 |
^ true |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
79 |
]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
80 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
81 |
^ super buttonPress:button x:x y:y view:aView |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
82 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
83 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
84 |
keyPress:key x:x y:y view:aView |
2612 | 85 |
aView == currentHelpView ifTrue:[ |
86 |
key == #Escape ifTrue:[ |
|
87 |
self hideHelp. |
|
88 |
^ true |
|
89 |
]. |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
90 |
]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
91 |
^ false |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
92 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
93 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
94 |
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
|
95 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
96 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
97 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
98 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
99 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
100 |
|
1540 | 101 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
102 |
aView == currentHelpView ifTrue:[^ true]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
103 |
^ super pointerLeave:state view:aView |
1540 | 104 |
! ! |
105 |
||
2392 | 106 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 107 |
|
108 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
109 |
"helper: ask aModel for its helpText." |
|
110 |
||
111 |
|text| |
|
112 |
||
113 |
aPointOrNil notNil ifTrue:[ |
|
114 |
(aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[ |
|
115 |
text := aModel flyByHelpTextFor:aView at:aPointOrNil. |
|
116 |
]. |
|
117 |
]. |
|
118 |
text isNil ifTrue:[ |
|
119 |
(aModel respondsTo:#flyByHelpTextFor:) ifTrue:[ |
|
120 |
text := aModel flyByHelpTextFor:aView. |
|
121 |
]. |
|
122 |
]. |
|
123 |
^ text |
|
124 |
! |
|
125 |
||
126 |
helpTextFromView:aView at:aPointOrNil |
|
127 |
"helper: ask aView for its helpText." |
|
128 |
||
129 |
|text| |
|
130 |
||
131 |
aPointOrNil notNil ifTrue:[ |
|
132 |
(aView respondsTo:#flyByHelpTextAt:) ifTrue:[ |
|
133 |
text := aView flyByHelpTextAt:aPointOrNil. |
|
134 |
]. |
|
135 |
]. |
|
136 |
text isNil ifTrue:[ |
|
137 |
(aView respondsTo:#flyByHelpText) ifTrue:[ |
|
138 |
text := aView flyByHelpText. |
|
139 |
]. |
|
140 |
]. |
|
141 |
^ text. |
|
2392 | 142 |
! ! |
143 |
||
144 |
!FlyByHelp methodsFor:'private'! |
|
1536 | 145 |
|
146 |
hideIfPointerLeft:aView |
|
147 |
"hide help, if the pointer is not in aView" |
|
148 |
||
149 |
|whereOnScreen| |
|
150 |
||
151 |
currentFrame notNil ifTrue:[ |
|
152 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
153 |
||
154 |
(currentFrame notNil |
|
155 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
156 |
self hideHelp. |
|
157 |
]. |
|
158 |
]. |
|
159 |
||
160 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
|
161 |
! |
|
162 |
||
163 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
164 |
"ask aView for helpText, passing x/y coordinates; |
|
165 |
start a timeout process to display this helpText after some delay; |
|
166 |
Normally used internally, but can also be used by widgets to force |
|
167 |
re-negotiation of the displayed helpText |
|
168 |
(for example in a menu, when the selection changes)" |
|
169 |
||
2392 | 170 |
|text delayTime| |
1536 | 171 |
|
172 |
(self interestedIn:aView) ifFalse:[ |
|
173 |
^ self |
|
174 |
]. |
|
175 |
||
176 |
text := self helpTextFor:aView at:aPointOrNil. |
|
177 |
lastHelpText = text ifTrue:[ |
|
2392 | 178 |
self toolTipFollowsMouse ifFalse:[ |
179 |
^ self |
|
180 |
] |
|
1536 | 181 |
]. |
182 |
||
183 |
text size > 0 ifTrue:[ |
|
2392 | 184 |
delayTime := self delayTime. |
185 |
(showItNow not and:[delayTime > 0]) ifTrue:[ |
|
1536 | 186 |
self stopHelpDisplayProcess. |
2392 | 187 |
showProcess := |
188 |
[ |
|
189 |
Delay waitForSeconds:delayTime. |
|
190 |
showProcess := nil. |
|
191 |
aView device anyButtonPressed ifFalse:[ |
|
192 |
self showHelp:text for:aView |
|
193 |
] |
|
194 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
1536 | 195 |
] ifFalse:[ |
196 |
self showHelp:text for:aView |
|
197 |
] |
|
1542 | 198 |
] ifFalse:[ |
199 |
self hideHelp |
|
1536 | 200 |
]. |
201 |
! |
|
202 |
||
203 |
interestedIn:aView |
|
204 |
"return true, if I am interested in aView (either listeningForAll, |
|
205 |
or in my list of apps)" |
|
206 |
||
207 |
aView isNil ifTrue:[^ false]. |
|
2495
728d6935dc5b
also interestedIn: help, if a pointer moves
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
208 |
"/ aView topView == currentHelpView ifTrue:[^ false]. |
1536 | 209 |
|
210 |
^ super interestedIn:aView |
|
211 |
! ! |
|
212 |
||
2392 | 213 |
!FlyByHelp methodsFor:'queries'! |
214 |
||
215 |
toolTipFollowsMouse |
|
216 |
^ false |
|
217 |
! ! |
|
218 |
||
1768 | 219 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 220 |
|
221 |
hideHelp |
|
222 |
"hide the help text" |
|
223 |
||
224 |
|p| |
|
225 |
||
1540 | 226 |
lastHelpText := nil. |
1536 | 227 |
self stopHelpDisplayProcess. |
228 |
||
229 |
currentHelpView notNil ifTrue:[ |
|
230 |
[ |
|
231 |
currentHelpView destroy. |
|
232 |
currentHelpView := nil. |
|
233 |
currentView := nil. |
|
234 |
] valueUninterruptably |
|
235 |
]. |
|
236 |
currentFrame := nil. |
|
237 |
closeProcess notNil ifTrue:[ |
|
238 |
p := closeProcess. closeProcess := nil. |
|
239 |
p terminate. |
|
240 |
] |
|
241 |
||
242 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
|
243 |
! |
|
244 |
||
245 |
showHelp:aHelpText for:view |
|
246 |
"show the help text for aView" |
|
247 |
||
2651 | 248 |
|wg org p v dev| |
1536 | 249 |
|
2651 | 250 |
(wg := view windowGroup) notNil ifTrue:[ |
251 |
wg isInModalLoop ifTrue:[ |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
252 |
"/ Transcript showCR:'1'. |
2651 | 253 |
wg isModal ifFalse:[ |
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
254 |
"/ Transcript showCR:'2'. |
2651 | 255 |
^ self |
256 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
257 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
258 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
259 |
|
1536 | 260 |
view == currentView ifTrue:[ |
261 |
lastHelpText = aHelpText ifTrue:[ |
|
262 |
^ self |
|
263 |
] |
|
264 |
]. |
|
265 |
||
266 |
lastHelpText := aHelpText. |
|
267 |
||
268 |
closeProcess notNil ifTrue:[ |
|
269 |
p := closeProcess. closeProcess := nil. |
|
270 |
p terminate. |
|
271 |
]. |
|
272 |
currentHelpView notNil ifTrue:[ |
|
273 |
self hideHelp |
|
274 |
]. |
|
275 |
||
276 |
org := view originRelativeTo:nil. |
|
277 |
currentFrame := org extent:view extent. |
|
278 |
org :=org + (view extent // 2). |
|
279 |
||
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
280 |
dev := view graphicsDevice. |
1536 | 281 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
282 |
v := ActiveHelpView for:aHelpText onDevice:dev. |
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
283 |
|
1536 | 284 |
org := dev pointerPosition. |
1657 | 285 |
org := org + (0@18"24"). |
1536 | 286 |
(org x + v width) > dev width ifTrue:[ |
287 |
org := (org x - v width) @ org y |
|
288 |
]. |
|
289 |
(org y + v height) > dev height ifTrue:[ |
|
290 |
org := org x @ (org y - v height). |
|
291 |
]. |
|
292 |
||
293 |
v origin:org. |
|
294 |
v realize. |
|
295 |
v enableButtonMotionEvents. |
|
296 |
v enableMotionEvents. |
|
297 |
currentHelpView := v. |
|
2392 | 298 |
currentView := view. |
1536 | 299 |
|
2392 | 300 |
self showTime notNil ifTrue:[ |
301 |
closeProcess := [ |
|
1546 | 302 |
[ |
2392 | 303 |
(Delay forSeconds:self showTime) wait. |
304 |
[ |
|
305 |
currentHelpView notNil ifTrue:[ |
|
306 |
currentHelpView destroy. |
|
307 |
currentHelpView := nil. |
|
308 |
] |
|
309 |
] valueUninterruptably |
|
310 |
] ifCurtailed:[ |
|
311 |
closeProcess := nil. |
|
312 |
]. |
|
313 |
] newProcess. |
|
314 |
closeProcess priority:(Processor userSchedulingPriority + 1). |
|
315 |
closeProcess resume. |
|
316 |
]. |
|
1536 | 317 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
318 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
319 |
"Modified: / 16-03-2004 / 15:27:50 / cg" |
1536 | 320 |
! |
321 |
||
322 |
stopHelpDisplayProcess |
|
323 |
|p| |
|
324 |
||
325 |
showProcess notNil ifTrue:[ |
|
326 |
p := showProcess. showProcess := nil. |
|
327 |
p terminate. |
|
328 |
]. |
|
329 |
||
330 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
331 |
! ! |
|
332 |
||
333 |
!FlyByHelp class methodsFor:'documentation'! |
|
334 |
||
335 |
version |
|
2651 | 336 |
^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.27 2009-05-06 13:21:12 cg Exp $' |
1536 | 337 |
! ! |
1657 | 338 |
|
1536 | 339 |
FlyByHelp initialize! |