--- a/ActiveHelp.st Tue Oct 28 19:38:32 1997 +0100
+++ b/ActiveHelp.st Tue Oct 28 19:43:22 1997 +0100
@@ -13,7 +13,7 @@
EventListener subclass:#ActiveHelp
instanceVariableNames:'currentView currentHelpView currentFrame showProcess closeProcess
- lastHelpText'
+ lastHelpText listeningForAll applicationsOrTopViewsWithHelp'
classVariableNames:'DelayTime ShowTime TheOneAndOnlyHelpListener'
poolDictionaries:''
category:'Interface-Help'
@@ -39,11 +39,12 @@
documentation
"
The active help listener.
+
The one and only instance of myself intercepts incoming mouse & keyboard
events for the display device, being especially interested in view-enter/
leave events. When such an event arrives, it asks the corresponding view
or its model for a help message and display it via an ActiveHelpView.
- (actully, the view is first asked if it would like to display it itself
+ (actually, the view is first asked if it would like to display it itself
- for example, in some information-view).
The query for the helpText is repeated along the views superView chain,
@@ -79,6 +80,17 @@
help listener, this method should then return nil, to keep it silent.
+ Usage:
+ If help is to be shown for all views (as enabled by the launchers help menu),
+ use 'ActiveHelp start' and 'ActiveHelp stop'.
+
+ Individual apps may enable/disable active help for themself by:
+ 'ActiveHelp startFor:app' or 'ActiveHelp stopFor:app', passing either
+ the topView or the topViews application as argument.
+ This is usually done by applications which want to show contextHelp in
+ some infoView.
+
+
[author:]
Claus Gittinger
@@ -95,6 +107,41 @@
examples
"
+ Active Help for a single view
+ or app (whatever the global settings are):
+ Can be initiated by an app when its opened.
+ [exBegin]
+ |app top myAppClass|
+
+ Class withoutUpdatingChangesDo:[
+ myAppClass := ApplicationModel
+ subclass:#'Demos::DemoApp'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'demos'.
+
+ myAppClass
+ compile:'helpTextFor:aView Transcript showCR:''hello''. ^ ''this is some helpText'''.
+
+ ].
+ app := myAppClass new.
+
+ top := StandardSystemView new.
+ top extent:300@100.
+ top application:app.
+ top open.
+
+ ActiveHelp startFor:app.
+
+ Class withoutUpdatingChangesDo:[
+ myAppClass removeFromSystem
+ ]
+ [exEnd]
+
+
+ Active Help (for all views):
+
(make certain that activeHelp is turned on ...
... otherwise, you will see nothing)
@@ -199,36 +246,57 @@
"Modified: 27.4.1996 / 15:07:57 / cg"
! !
-!ActiveHelp class methodsFor:'startup'!
+!ActiveHelp class methodsFor:'start & stop'!
start
- "start activeHelp"
+ "start activeHelp for all apps"
TheOneAndOnlyHelpListener isNil ifTrue:[
TheOneAndOnlyHelpListener := self new.
].
- TheOneAndOnlyHelpListener listen
+ TheOneAndOnlyHelpListener listenForAll
"
ActiveHelp start
"
- "Modified: 27.4.1996 / 15:08:05 / cg"
+ "Modified: / 26.10.1997 / 23:16:54 / cg"
+!
+
+startFor:anApplicationOrTopView
+ "start activeHelp for a single app"
+
+ TheOneAndOnlyHelpListener isNil ifTrue:[
+ TheOneAndOnlyHelpListener := self new.
+ ].
+ TheOneAndOnlyHelpListener listenFor:anApplicationOrTopView
+
+ "Modified: / 26.10.1997 / 23:17:05 / cg"
!
stop
- "stop activeHelp"
+ "stop activeHelp for all (except for individual apps)"
TheOneAndOnlyHelpListener notNil ifTrue:[
- TheOneAndOnlyHelpListener unlisten.
+ TheOneAndOnlyHelpListener unlistenAll.
].
- TheOneAndOnlyHelpListener := nil
"
ActiveHelp stop
"
- "Modified: 27.4.1996 / 15:08:11 / cg"
+ "Modified: / 26.10.1997 / 23:18:58 / cg"
+!
+
+stopFor:anAppOrTopView
+ "stop activeHelp for a single app"
+
+ TheOneAndOnlyHelpListener notNil ifTrue:[
+ TheOneAndOnlyHelpListener unlistenFor:anAppOrTopView.
+ ].
+
+ "Modified: / 26.10.1997 / 23:12:55 / cg"
+ "Created: / 26.10.1997 / 23:18:41 / cg"
! !
!ActiveHelp class methodsFor:'times'!
@@ -292,16 +360,20 @@
pointerEnter:state x:x y:y view:aView
"handle pointer entering a view; setup timeOut to show help"
- self stopHelpDisplayProcess.
- self hideIfPointerLeft:aView.
+ "/ ignore my own help-view
aView topView == currentHelpView ifTrue:[
- ^ true
+ ^ true
].
- self initiateHelpFor:aView atX:x y:y.
+ (self interestedIn:aView) ifTrue:[
+ self stopHelpDisplayProcess.
+ self hideIfPointerLeft:aView.
+
+ self initiateHelpFor:aView atX:x y:y.
+ ].
^ false
- "Modified: 28.6.1997 / 14:04:09 / cg"
+ "Modified: / 26.10.1997 / 23:26:28 / cg"
!
pointerLeave:state view:view
@@ -432,6 +504,23 @@
"Modified: 28.5.1996 / 20:18:28 / cg"
!
+interestedIn:aView
+ "am I interested in aView (either listeningForAll,
+ or in my list of apps"
+
+ |app|
+
+ listeningForAll == true ifTrue:[^ true].
+ (applicationsOrTopViewsWithHelp includesIdentical:(aView topView)) ifTrue:[^ true].
+ app := aView topView application.
+ app notNil ifTrue:[
+ (applicationsOrTopViewsWithHelp includesIdentical:app) ifTrue:[^ true]
+ ].
+ ^ false
+
+ "Created: / 26.10.1997 / 23:28:52 / cg"
+!
+
stopHelpDisplayProcess
|p|
@@ -597,20 +686,62 @@
"Modified: 28.6.1997 / 14:45:15 / cg"
! !
-!ActiveHelp methodsFor:'stopping'!
+!ActiveHelp methodsFor:'start & stop'!
+
+listenFor:anAppOrTopView
+ "start listening"
+
+ applicationsOrTopViewsWithHelp isNil ifTrue:[
+ applicationsOrTopViewsWithHelp := WeakIdentitySet new.
+ ].
+ applicationsOrTopViewsWithHelp add:anAppOrTopView.
+ super listen.
-unlisten
+ "Created: / 26.10.1997 / 23:20:47 / cg"
+ "Modified: / 26.10.1997 / 23:21:10 / cg"
+!
+
+listenForAll
+ "start listening"
+
+ listeningForAll := true.
+ super listen.
+
+ "Modified: / 28.6.1997 / 15:07:02 / cg"
+ "Created: / 26.10.1997 / 23:19:30 / cg"
+!
+
+unlistenAll
"stop listening"
self hideHelp.
- super unlisten.
+ listeningForAll := false.
+ applicationsOrTopViewsWithHelp size == 0 ifTrue:[
+ super unlisten.
+ ]
+
+ "Created: / 26.10.1997 / 23:14:17 / cg"
+ "Modified: / 26.10.1997 / 23:23:04 / cg"
+!
- "Modified: 28.6.1997 / 15:07:02 / cg"
+unlistenFor:anApp
+ "stop listening for an app"
+
+ self hideHelp.
+ applicationsOrTopViewsWithHelp remove:anApp ifAbsent:nil.
+ listeningForAll ifFalse:[
+ applicationsOrTopViewsWithHelp size == 0 ifTrue:[
+ super unlisten.
+ ]
+ ]
+
+ "Modified: / 26.10.1997 / 23:17:43 / cg"
+ "Created: / 26.10.1997 / 23:22:42 / cg"
! !
!ActiveHelp class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.28 1997-09-15 20:25:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.29 1997-10-28 18:43:22 cg Exp $'
! !
ActiveHelp initialize!