ActiveHelp.st
author Claus Gittinger <cg@exept.de>
Sat, 28 Jun 1997 14:06:53 +0200
changeset 633 5d162347fac8
parent 632 844b1aaf3eeb
child 634 1d88f55984a2
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     1
"
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     4
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    11
"
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    12
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    13
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    14
EventListener subclass:#ActiveHelp
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
    15
	instanceVariableNames:'currentView currentHelpView currentFrame showProcess closeProcess
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
    16
		lastHelpText'
216
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    17
	classVariableNames:'DelayTime ShowTime TheOneAndOnlyHelpListener'
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    18
	poolDictionaries:''
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    19
	category:'Interface-Help'
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    20
!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    21
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    22
!ActiveHelp class methodsFor:'documentation'!
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    23
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    24
copyright
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    25
"
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    27
	      All Rights Reserved
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    28
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    29
 This software is furnished under a license and may be used
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    30
 only in accordance with the terms of that license and with the
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    32
 be provided or otherwise made available to, or used by, any
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    33
 other person.  No title to or ownership of the software is
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    34
 hereby transferred.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    35
"
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    36
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    37
!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    38
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    39
documentation
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
    40
"
98
claus
parents: 97
diff changeset
    41
    The active help listener.
claus
parents: 97
diff changeset
    42
    The one and only instance of myself intercepts incoming mouse & keyboard 
claus
parents: 97
diff changeset
    43
    events for the display device, being especially interested in view-enter/
100
claus
parents: 98
diff changeset
    44
    leave enents. When such an event arrives, it asks the corresponding view
98
claus
parents: 97
diff changeset
    45
    or its model for a help message and display it via an ActiveHelpView.
100
claus
parents: 98
diff changeset
    46
    This query is repeated along the views superView chain, until any model or
claus
parents: 98
diff changeset
    47
    view returns a nonNil answer for the #helpTextFor:at or #helpTextFor
claus
parents: 98
diff changeset
    48
    message.
claus
parents: 98
diff changeset
    49
98
claus
parents: 97
diff changeset
    50
    All I need for automatic help is some model/view/applicationModel along
claus
parents: 97
diff changeset
    51
    the superview chain of the entered component, which responds to the
claus
parents: 97
diff changeset
    52
    #helpTextFor: message with a non-nil (string-) answer.
claus
parents: 97
diff changeset
    53
    I close down the help view after a while, if a key is pressed or the mouse
claus
parents: 97
diff changeset
    54
    moved to another view.
100
claus
parents: 98
diff changeset
    55
claus
parents: 98
diff changeset
    56
    Who should provide the helpText:
claus
parents: 98
diff changeset
    57
221
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    58
        the best place is the application object (an instance of ApplicationModel)
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    59
        or the topView, if its a derived class of StandardSystemView.
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    60
        This should know about its components and return the string
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    61
        when asked via #helpTextFor:aComponent.
330
d7ce98930ad3 Rename Launcher-->OldLauncher, NewLauncher-->Launcher.
Stefan Vogel <sv@exept.de>
parents: 297
diff changeset
    62
        See examples in FileBrowser, Launcher etc.
100
claus
parents: 98
diff changeset
    63
claus
parents: 98
diff changeset
    64
    Be aware, that for applicationModels, there must be a link from the
claus
parents: 98
diff changeset
    65
    topView to this applicationModel 
claus
parents: 98
diff changeset
    66
    (set via: aTopView application:anApplicationModel)
claus
parents: 98
diff changeset
    67
    otherwise, the helpManager has no means of finding the application which
claus
parents: 98
diff changeset
    68
    corresponds to a view.
claus
parents: 98
diff changeset
    69
claus
parents: 98
diff changeset
    70
    Who should display the helpText:
claus
parents: 98
diff changeset
    71
221
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    72
        by default, the helpListener opens a little popup view, which displays the
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    73
        returned help message. However, a nice trick which can be used by applications
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    74
        is to create an infoLabel as a subview of the topFrame (a la windows)
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    75
        and display the text right in the #helpTextFor: method. To cheat the
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    76
        help listener, this method should then return nil, to keep it silent.
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    77
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    78
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    79
    [author:]
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    80
        Claus Gittinger
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    81
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    82
    [start with:]
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    83
        ActiveHelp start
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    84
        ActiveHelp stop
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    85
221
ea942fe5dc04 documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    86
    [See also:]
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    87
        ActiveHelpView
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    88
        WindowGroup WindowEvent
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    89
        ApplicationModel StandardSystemView
100
claus
parents: 98
diff changeset
    90
"
claus
parents: 98
diff changeset
    91
!
claus
parents: 98
diff changeset
    92
claus
parents: 98
diff changeset
    93
examples
claus
parents: 98
diff changeset
    94
"
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    95
    (make certain that activeHelp is turned on ...
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
    96
     ... otherwise, you will see nothing)
100
claus
parents: 98
diff changeset
    97
claus
parents: 98
diff changeset
    98
    the following example uses a Plug as a model replacement.
claus
parents: 98
diff changeset
    99
    In concrete application, you would create a method to implement the helpText
claus
parents: 98
diff changeset
   100
    query message.
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   101
                                                                        [exBegin]
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   102
        |app top button1 button2|
100
claus
parents: 98
diff changeset
   103
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   104
        app := Plug new.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   105
        app respondTo:#helpTextFor:
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   106
                 with:[:view | 
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   107
                               view == button1 ifTrue:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   108
                                 'this is button1'
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   109
                               ] ifFalse:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   110
                                 view == button2 ifTrue:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   111
                                   'some help for button2'
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   112
                                 ] ifFalse:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   113
                                   nil
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   114
                                 ]
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   115
                               ]
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   116
                      ].
100
claus
parents: 98
diff changeset
   117
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   118
        top := StandardSystemView new.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   119
        top extent:300@100.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   120
        button1 := Button label:'b1' in:top.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   121
        button1 origin:0.0@0.0 corner:0.5@30. 
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   122
        button2 := Button label:'b2' in:top.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   123
        button2 origin:0.5@0.0 corner:1.0@30.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   124
        top model:app. '<-- normally this would be: top application:app'.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   125
        top open
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   126
                                                                        [exEnd]
100
claus
parents: 98
diff changeset
   127
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   128
    (make certain that activeHelp is turned on ...
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   129
     ... otherwise, you will see nothing)
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   130
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   131
    alternatively, display of the helpMessage in a local, private view:
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   132
                                                                        [exBegin]
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   133
        |app top button1 button2 infoView|
100
claus
parents: 98
diff changeset
   134
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   135
        app := Plug new.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   136
        app respondTo:#helpTextFor:
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   137
                 with:[:view | infoView label:'info ...'.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   138
                               view == button1 ifTrue:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   139
                                 infoView label:'this is button1'
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   140
                               ].
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   141
                               view == button2 ifTrue:[
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   142
                                 infoView label:'some help for button2'
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   143
                               ].
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   144
                               nil
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   145
                      ].
100
claus
parents: 98
diff changeset
   146
227
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   147
        top := StandardSystemView new.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   148
        top extent:300@100.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   149
        button1 := Button label:'b1' in:top.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   150
        button1 origin:0.0@0.0 corner:0.5@30. 
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   151
        button2 := Button label:'b2' in:top.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   152
        button2 origin:0.5@0.0 corner:1.0@30.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   153
        infoView := Label label:'info ...' in:top.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   154
        infoView level:-1; origin:0.0@1.0 corner:1.0@1.0.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   155
        infoView topInset:(infoView preferredExtent y negated - 3);
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   156
                 leftInset:3; 
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   157
                 rightInset:3; 
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   158
                 bottomInset:3;
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   159
                 adjust:#left.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   160
        top model:app. '<-- normally this would be: top application:app'.
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   161
        top open
3f18af678ac9 examples for docViewer
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   162
                                                                        [exEnd]
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   163
"
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   164
! !
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   165
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   166
!ActiveHelp class methodsFor:'initialization'!
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   167
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   168
initialize
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   169
    "set default delay & help-display times"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   170
92
claus
parents: 59
diff changeset
   171
    ShowTime := 15.
100
claus
parents: 98
diff changeset
   172
    DelayTime := 2.
92
claus
parents: 59
diff changeset
   173
claus
parents: 59
diff changeset
   174
    "
claus
parents: 59
diff changeset
   175
     ActiveHelp initialize
claus
parents: 59
diff changeset
   176
    "
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   177
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   178
    "Modified: 27.4.1996 / 15:07:27 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   179
! !
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   180
633
5d162347fac8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   181
!ActiveHelp class methodsFor:'queries'!
100
claus
parents: 98
diff changeset
   182
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   183
currentHelpListener
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   184
    "return the activeHelp listener if activeHelp is turned on, nil otherwise"
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   185
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   186
    ^ TheOneAndOnlyHelpListener
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   187
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   188
    "Created: 28.6.1997 / 13:59:44 / cg"
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   189
!
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   190
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   191
isActive
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   192
    "return true, if activeHelp is turned on"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   193
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   194
    ^ TheOneAndOnlyHelpListener notNil
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   195
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   196
    "Modified: 27.4.1996 / 15:07:57 / cg"
633
5d162347fac8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   197
! !
5d162347fac8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   198
5d162347fac8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   199
!ActiveHelp class methodsFor:'startup'!
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   200
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   201
start
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   202
    "start activeHelp"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   203
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   204
    TheOneAndOnlyHelpListener isNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   205
        TheOneAndOnlyHelpListener := self new.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   206
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   207
    TheOneAndOnlyHelpListener listen
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   208
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   209
    "
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   210
     ActiveHelp start
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   211
    "
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   212
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   213
    "Modified: 27.4.1996 / 15:08:05 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   214
!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   215
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   216
stop
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   217
    "stop activeHelp"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   218
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   219
    TheOneAndOnlyHelpListener notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   220
        TheOneAndOnlyHelpListener unlisten.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   221
    ].
92
claus
parents: 59
diff changeset
   222
    TheOneAndOnlyHelpListener := nil
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   223
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   224
    "
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   225
     ActiveHelp stop
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   226
    "
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   227
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   228
    "Modified: 27.4.1996 / 15:08:11 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   229
! !
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   230
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   231
!ActiveHelp class methodsFor:'times'!
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   232
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   233
delayTime:numberOfSeconds
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   234
    "set the delay (the time, the cursor has to be in the view
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   235
     before help is shown). The default is 2 seconds."
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   236
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   237
    DelayTime := numberOfSeconds
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   238
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   239
    "
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   240
     ActiveHelp delayTime:0.5
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   241
     ActiveHelp delayTime:2
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   242
     ActiveHelp delayTime:10
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   243
    "
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   244
!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   245
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   246
showTime:numberOfSeconds
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   247
    "set the number of seconds, a help messages is to be shown.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   248
     The default is 15 seconds."
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   249
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   250
    ShowTime := numberOfSeconds
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   251
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   252
    "
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   253
     ActiveHelp showTime:10
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   254
     ActiveHelp showTime:99999 
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   255
     ActiveHelp showTime:30
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   256
    "
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   257
! !
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   258
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   259
!ActiveHelp methodsFor:'listening'!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   260
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   261
buttonMotion:state x:x y:y view:view
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   262
    "handle motion events - if the mousepointer left the 
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   263
     previous helped view, hide the help"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   264
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   265
    self hideIfPointerLeft:view.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   266
    ^ false
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   267
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   268
    "Modified: 27.4.1996 / 15:09:48 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   269
!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   270
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   271
buttonPress:state x:x y:y view:view
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   272
    "handle button press - unconditionally hide the help"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   273
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   274
    self hideHelp.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
    ^ false
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   276
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   277
    "Modified: 27.4.1996 / 15:09:45 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   278
!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   279
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   280
keyPress:state x:x y:y view:view
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   281
    "handle key press - unconditionally hide the help"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   282
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   283
    self hideHelp.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   284
    ^ false
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   285
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   286
    "Modified: 27.4.1996 / 15:09:57 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   287
!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   288
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   289
pointerEnter:state x:x y:y view:aView
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   290
    "handle pointer entering a view; setup timeOut to show help"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   291
344
42ae71c13eef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
   292
    |p|
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   293
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   294
    self stopHelpDisplayProcess.
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   295
    self hideIfPointerLeft:aView.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   296
    aView topView == currentHelpView ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   297
        ^ true
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   298
    ].
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   299
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   300
    self initiateHelpFor:aView atX:x y:y.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   301
    ^ false
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   302
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   303
    "Modified: 28.6.1997 / 14:04:09 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   304
!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   305
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   306
pointerLeave:state view:view
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   307
    "handle pointer leaving a view; hide help text"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   308
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   309
    self hideIfPointerLeft:view.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   310
    ^ false
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   311
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   312
    "Modified: 27.4.1996 / 15:10:41 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   313
! !
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   314
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   315
!ActiveHelp methodsFor:'private'!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   316
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   317
helpTextFor:aView atX:x y:y
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   318
    "retrieve helptext for aView as a string; 
100
claus
parents: 98
diff changeset
   319
     walk along the views superView chain,
claus
parents: 98
diff changeset
   320
     asking models and views encountered while walking.
claus
parents: 98
diff changeset
   321
     The first one who understands and returns a nonNil answer to the
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   322
     #helpTextFor:at: or #helpTextFor: message ends this search and the
100
claus
parents: 98
diff changeset
   323
     returned string is returned."
claus
parents: 98
diff changeset
   324
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   325
    |model app text view v sv|
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   326
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   327
    view := aView.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   328
    (model := aView model) notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   329
        (model respondsTo:#helpTextFor:at:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   330
            text := model helpTextFor:aView at:x@y.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   331
            text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   332
        ].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   333
        (model respondsTo:#helpTextFor:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   334
            text := model helpTextFor:aView.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   335
            text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   336
        ]
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   337
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   338
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   339
    (aView respondsTo:#helpText) ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   340
        text := aView helpText.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   341
        text notNil ifTrue:[^ text].
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   342
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   343
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   344
    "walk up the chain - maybe someone knows about its subview ..."
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   345
    v := aView.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   346
296
c7ae52588794 #superView -> #container
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   347
    [(sv := v container) notNil] whileTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   348
        (model := sv model) notNil ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   349
            (model respondsTo:#helpTextFor:at:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   350
                text := model helpTextFor:aView at:x@y.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   351
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   352
            ].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   353
            (model respondsTo:#helpTextFor:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   354
                text := model helpTextFor:aView.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   355
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   356
            ]
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   357
        ].
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   358
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   359
        (sv respondsTo:#helpTextFor:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   360
            text := sv helpTextFor:aView.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   361
            text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   362
            text := sv helpTextFor:v.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   363
            text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   364
         ].
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   365
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   366
         v := sv.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   367
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   368
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   369
    (aView respondsTo:#application) ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   370
        (app := aView application) notNil ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   371
            (app respondsTo:#helpTextFor:at:) ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   372
                text := app helpTextFor:aView at:x@y.
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   373
                text notNil ifTrue:[^ text].
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   374
            ].
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   375
            (app respondsTo:#helpTextFor:) ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   376
                text := app helpTextFor:aView.
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   377
                text notNil ifTrue:[^ text].
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   378
            ]
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   379
        ]
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   380
    ].
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   381
100
claus
parents: 98
diff changeset
   382
    (v notNil and:[v respondsTo:#application]) ifTrue:[
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   383
        (app := v application) notNil ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   384
            (app respondsTo:#helpTextFor:at:) ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   385
                text := app helpTextFor:aView at:x@y.
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   386
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   387
            ].
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   388
            (app respondsTo:#helpTextFor:) ifTrue:[
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   389
                text := app helpTextFor:aView.
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   390
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   391
            ]
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   392
        ]
100
claus
parents: 98
diff changeset
   393
    ].
claus
parents: 98
diff changeset
   394
    (v notNil and:[v respondsTo:#model]) ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   395
        (model := v model) notNil ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   396
            (model respondsTo:#helpTextFor:at:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   397
                text := model helpTextFor:aView at:x@y.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   398
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   399
            ].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   400
            (model respondsTo:#helpTextFor:) ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   401
                text := model helpTextFor:aView.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   402
                text notNil ifTrue:[^ text].
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   403
            ]
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   404
        ]
100
claus
parents: 98
diff changeset
   405
    ].
claus
parents: 98
diff changeset
   406
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   407
    (view class respondsTo:#helpText) ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   408
        text := view class helpText.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   409
        text notNil ifTrue:[^ text].
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   410
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   411
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   412
    ^ nil
100
claus
parents: 98
diff changeset
   413
claus
parents: 98
diff changeset
   414
    "Modified: 31.8.1995 / 20:38:00 / claus"
296
c7ae52588794 #superView -> #container
Claus Gittinger <cg@exept.de>
parents: 276
diff changeset
   415
    "Modified: 5.6.1996 / 14:18:23 / cg"
100
claus
parents: 98
diff changeset
   416
!
claus
parents: 98
diff changeset
   417
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   418
hideIfPointerLeft:aView
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   419
    "hide help, if the pointer is not in aView"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   420
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   421
    |whereOnScreen p|
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   422
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   423
"/    showProcess notNil ifTrue:[
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   424
"/        p := showProcess. showProcess := nil.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   425
"/        p terminate.
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   426
"/    ].
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   427
276
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   428
    whereOnScreen := aView graphicsDevice pointerPosition.
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   429
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   430
    (currentFrame notNil
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   431
    and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   432
        self hideHelp.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   433
        currentView := nil
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   434
    ].
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   435
276
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   436
    "Modified: 28.5.1996 / 20:18:28 / cg"
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   437
!
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   438
100
claus
parents: 98
diff changeset
   439
initiateHelpFor:aView atX:x y:y
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   440
    "start a timeout process to display help for aView after some delay"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   441
100
claus
parents: 98
diff changeset
   442
    |text p|
claus
parents: 98
diff changeset
   443
claus
parents: 98
diff changeset
   444
    text := self helpTextFor:aView atX:x y:y.
claus
parents: 98
diff changeset
   445
claus
parents: 98
diff changeset
   446
    text notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   447
        DelayTime > 0 ifTrue:[
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   448
            self stopHelpDisplayProcess.
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   449
            showProcess := [
297
14971808870c #superView -> #container
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
   450
                    Delay waitForSeconds:DelayTime.
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   451
                    showProcess := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   452
                    self showHelp:text for:aView
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   453
            ] forkAt:(Processor userSchedulingPriority + 1).
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   454
        ] ifFalse:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   455
            self showHelp:text for:aView
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   456
        ]
100
claus
parents: 98
diff changeset
   457
    ].
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   458
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   459
    "Modified: 28.6.1997 / 14:05:33 / cg"
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   460
!
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   461
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   462
stopHelpDisplayProcess
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   463
    |p|
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   464
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   465
    showProcess notNil ifTrue:[
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   466
        p := showProcess. showProcess := nil.
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   467
        p terminate.
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   468
    ].
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   469
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   470
    "Created: 28.6.1997 / 14:03:17 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   471
! !
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   472
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   473
!ActiveHelp methodsFor:'show / hide help'!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   474
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   475
hideHelp
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   476
    "hide the help text"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   477
98
claus
parents: 97
diff changeset
   478
    |p|
claus
parents: 97
diff changeset
   479
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   480
    self stopHelpDisplayProcess.
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   481
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   482
    currentHelpView notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   483
        [
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   484
            currentHelpView destroy.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   485
            currentHelpView := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   486
            currentView := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   487
        ] valueUninterruptably
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   488
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   489
    currentFrame := nil.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   490
    closeProcess notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   491
        p := closeProcess. closeProcess := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   492
        p terminate.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   493
    ]
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   494
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   495
    "Modified: 28.6.1997 / 14:03:50 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   496
!
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   497
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   498
showHelp:aHelpText for:view
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   499
    "show the help text for aView"
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   500
596
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   501
    |org p v dev top app|
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   502
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   503
    view == currentView ifTrue:[
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   504
        lastHelpText = aHelpText ifTrue:[
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   505
            ^ self
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   506
        ]
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   507
    ].
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   508
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   509
    lastHelpText := aHelpText.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   510
596
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   511
    "/ give the views application a chance
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   512
    "/ to decide where to show the help text
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   513
    "/ (i.e. in its own information area)
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   514
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   515
    top := view topView.
602
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   516
b1ac53a44327 application and help
ca
parents: 596
diff changeset
   517
    (app := view application) notNil ifTrue:[
596
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   518
        (app showHelp:aHelpText for:view) ifTrue:[
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   519
            ^ self
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   520
        ]
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   521
    ].
a184f2e4dbbb give the views application a chance
ca
parents: 344
diff changeset
   522
92
claus
parents: 59
diff changeset
   523
    closeProcess notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   524
        p := closeProcess. closeProcess := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   525
        p terminate.
92
claus
parents: 59
diff changeset
   526
    ].
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   527
    currentHelpView notNil ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   528
        self hideHelp
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   529
    ].
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   530
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   531
    org := view originRelativeTo:nil.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   532
    currentFrame := org extent:view extent.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   533
    org :=org + (view extent // 2).
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   534
100
claus
parents: 98
diff changeset
   535
    v := ActiveHelpView for:aHelpText withCRs.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   536
276
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   537
    dev := view graphicsDevice.
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   538
    org := dev pointerPosition.
100
claus
parents: 98
diff changeset
   539
    org := org + (10@10).
276
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   540
    (org x + v width) > dev width ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   541
        org := (org x - v width) @ org y
92
claus
parents: 59
diff changeset
   542
    ].
276
19b205dde532 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 233
diff changeset
   543
    (org y + v height) > dev height ifTrue:[
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   544
        org := org x @ (org y - v height).
92
claus
parents: 59
diff changeset
   545
    ].
claus
parents: 59
diff changeset
   546
100
claus
parents: 98
diff changeset
   547
    v origin:org.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   548
"/    currentHelpView open.
100
claus
parents: 98
diff changeset
   549
    v realize.
claus
parents: 98
diff changeset
   550
    v enableButtonMotionEvents.
claus
parents: 98
diff changeset
   551
    v enableMotionEvents.
claus
parents: 98
diff changeset
   552
    currentHelpView := v.
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   553
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   554
    currentView := view.
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   555
    closeProcess := [
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   556
        [
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   557
            (Delay forSeconds:ShowTime) wait.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   558
            [
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   559
                currentHelpView notNil ifTrue:[
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   560
                    currentHelpView destroy.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   561
                    currentHelpView := nil.
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   562
                ]
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   563
            ] valueUninterruptably
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   564
        ] valueOnUnwindDo:[
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   565
            closeProcess := nil.
233
196eb68b707c documentation
Claus Gittinger <cg@exept.de>
parents: 227
diff changeset
   566
        ].
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   567
    ] forkAt:(Processor userSchedulingPriority + 1).
100
claus
parents: 98
diff changeset
   568
claus
parents: 98
diff changeset
   569
    "Modified: 31.8.1995 / 19:20:45 / claus"
632
844b1aaf3eeb provide access to the current activeHelp instance
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   570
    "Modified: 28.6.1997 / 14:02:26 / cg"
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   571
! !
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   572
338
071f92621e3b oops - catching the terminateSignal is no good idea
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   573
!ActiveHelp class methodsFor:'documentation'!
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   574
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   575
version
633
5d162347fac8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   576
    ^ '$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.22 1997-06-28 12:06:53 cg Exp $'
138
492fb73ca439 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   577
! !
59
98a4d38cfc96 Initial revision
claus
parents:
diff changeset
   578
ActiveHelp initialize!