KeyboardForwarder.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 7660 7541edd3ab40
child 8362 573b5a8cc1c5
permissions -rw-r--r--
#BUGFIX by Maren class: DeviceGraphicsContext changed: #displayDeviceOpaqueForm:x:y: nil check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
128
9c2378152500 Initial revision
claus
parents:
diff changeset
     1
"
9c2378152500 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
9c2378152500 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
9c2378152500 Initial revision
claus
parents:
diff changeset
     4
9c2378152500 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
9c2378152500 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
9c2378152500 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
9c2378152500 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
9c2378152500 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
9c2378152500 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
9c2378152500 Initial revision
claus
parents:
diff changeset
    11
"
3682
d756fdb95712 evenTypes - private to windowEvent
ca
parents: 3094
diff changeset
    12
"{ Package: 'stx:libview' }"
d756fdb95712 evenTypes - private to windowEvent
ca
parents: 3094
diff changeset
    13
7660
7541edd3ab40 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
    14
"{ NameSpace: Smalltalk }"
7541edd3ab40 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
    15
128
9c2378152500 Initial revision
claus
parents:
diff changeset
    16
Object subclass:#KeyboardForwarder
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
    17
	instanceVariableNames:'sourceView destinationView destination condition filter'
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
    18
	classVariableNames:''
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
    19
	poolDictionaries:''
5277
27d26caa8086 category change
Claus Gittinger <cg@exept.de>
parents: 3682
diff changeset
    20
	category:'Interface-Support-UI'
128
9c2378152500 Initial revision
claus
parents:
diff changeset
    21
!
9c2378152500 Initial revision
claus
parents:
diff changeset
    22
9c2378152500 Initial revision
claus
parents:
diff changeset
    23
!KeyboardForwarder class methodsFor:'documentation'!
9c2378152500 Initial revision
claus
parents:
diff changeset
    24
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    25
copyright
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    26
"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    28
	      All Rights Reserved
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    29
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    30
 This software is furnished under a license and may be used
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    31
 only in accordance with the terms of that license and with the
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    33
 be provided or otherwise made available to, or used by, any
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    34
 other person.  No title to or ownership of the software is
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    35
 hereby transferred.
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    36
"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    37
128
9c2378152500 Initial revision
claus
parents:
diff changeset
    38
!
9c2378152500 Initial revision
claus
parents:
diff changeset
    39
9c2378152500 Initial revision
claus
parents:
diff changeset
    40
documentation
9c2378152500 Initial revision
claus
parents:
diff changeset
    41
"
144
claus
parents: 142
diff changeset
    42
    Instances of this class can be used to forward keyboard
claus
parents: 142
diff changeset
    43
    events to some object or other view (install them via aView delegate:).
claus
parents: 142
diff changeset
    44
    Event delegation allows to add additional keyboard functions to views
claus
parents: 142
diff changeset
    45
    WITHOUT modifying their code or changing controllers.
claus
parents: 142
diff changeset
    46
    Also, it allows to catch certain individual keys to ignore them or
claus
parents: 142
diff changeset
    47
    perform different functions.
claus
parents: 142
diff changeset
    48
7660
7541edd3ab40 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
    49
    Notice, that delegates don't have to be instances of
128
9c2378152500 Initial revision
claus
parents:
diff changeset
    50
    myself; any object with a protocol similar to mine can be used as
9c2378152500 Initial revision
claus
parents:
diff changeset
    51
    a delegate. 
142
claus
parents: 140
diff changeset
    52
    (i.e. any object that responds to 
claus
parents: 140
diff changeset
    53
     handlesKeyPress:view: / keyPress:x:y:view: / delegatesTo: etc.)
139
claus
parents: 134
diff changeset
    54
claus
parents: 134
diff changeset
    55
    However, I provide the most common functions required for conditional
claus
parents: 134
diff changeset
    56
    event delegation and instances of myself are for example used to forward 
claus
parents: 134
diff changeset
    57
    events from elements of some dialogBoxes to the enterfield/fieldGroup - 
144
claus
parents: 142
diff changeset
    58
    (which allows keyboard input to be forwarded to the active text-field even 
claus
parents: 142
diff changeset
    59
     while the mouse pointer is somewhere else)
139
claus
parents: 134
diff changeset
    60
claus
parents: 134
diff changeset
    61
    Another application of delegation is to catch keyboard input to some standard
claus
parents: 134
diff changeset
    62
    widget, optionally processing and resending the key-event.
128
9c2378152500 Initial revision
claus
parents:
diff changeset
    63
144
claus
parents: 142
diff changeset
    64
    I can either forward the key event to another view, or to some general
claus
parents: 142
diff changeset
    65
    object - the difference is that views are sent a #keyXXX:x:y: message,
claus
parents: 142
diff changeset
    66
    while general destinations get a #keyXXX:x:y:view: message, with the original
claus
parents: 142
diff changeset
    67
    view (the one in which the event occurred) as additional argument.
claus
parents: 142
diff changeset
    68
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    69
    [Instance Variables:]
139
claus
parents: 134
diff changeset
    70
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    71
        destinationView         <View>          the view which shall receive
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    72
                                                the forwarded keyboard events.
134
claus
parents: 128
diff changeset
    73
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    74
        destination             <Object>        the object which shall receive
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    75
                                                the forwarded keyboard events.
139
claus
parents: 134
diff changeset
    76
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    77
        sourceView              <ViewOrNil>     if non-nil, only events from this
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    78
                                                view are forwarded.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    79
                                                (currently nowhere used)
134
claus
parents: 128
diff changeset
    80
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    81
        condition               <Symbol>        an additional condition for forwarding
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    82
                                                currently only #noFocus is implemented.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    83
                                                The #noFocus condition will only forward
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    84
                                                events if no explicit focus has been
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    85
                                                set in the windowGroup.
144
claus
parents: 142
diff changeset
    86
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    87
                                <Block>         condition block - event is forwarded,
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    88
                                                if it evaluates to true.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    89
                                                The block gets 3 arguments:
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    90
                                                    eventType   #keyPress or #keyRelease
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    91
                                                    key         the key
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    92
                                                    view        the originating view
144
claus
parents: 142
diff changeset
    93
claus
parents: 142
diff changeset
    94
    For more info on event handling/forwarding, see the documentation in
claus
parents: 142
diff changeset
    95
    WindowSensor, WindowGroup and especially in WindowEvent.
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    96
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    97
    [see also:]
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    98
        WindowEvent WindowSensor WindowGroup
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    99
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   100
    [author:]
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
   101
        Claus Gittinger
144
claus
parents: 142
diff changeset
   102
"
claus
parents: 142
diff changeset
   103
!
claus
parents: 142
diff changeset
   104
claus
parents: 142
diff changeset
   105
examples
claus
parents: 142
diff changeset
   106
"
claus
parents: 142
diff changeset
   107
    catch an enterfields input:
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   108
                                                                        [exBegin]
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   109
        |top field forwarder catcher|
144
claus
parents: 142
diff changeset
   110
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   111
        catcher := Plug new.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   112
        catcher respondTo:#keyPress:x:y:view:
1752
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   113
                    with:[:key :x :y :view | Transcript showCR:'caught keyPress: ' , key printString.].
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   114
        catcher respondTo:#keyRelease:x:y:view:
1752
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   115
                    with:[:key :x :y :view | Transcript showCR:'caught keyRelease: ' , key printString.].
144
claus
parents: 142
diff changeset
   116
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   117
        top := StandardSystemView new.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   118
        top extent:200@200.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   119
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   120
        field := EditField in:top.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   121
        field origin:0.0@0.0; width:1.0.
144
claus
parents: 142
diff changeset
   122
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   123
        forwarder := KeyboardForwarder to:catcher. 
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   124
        field delegate:forwarder.
144
claus
parents: 142
diff changeset
   125
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   126
        top open
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   127
                                                                        [exEnd]
144
claus
parents: 142
diff changeset
   128
claus
parents: 142
diff changeset
   129
claus
parents: 142
diff changeset
   130
    catch an enterfields return-key only:
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   131
                                                                        [exBegin]
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   132
        |top field forwarder catcher|
144
claus
parents: 142
diff changeset
   133
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   134
        catcher := Plug new.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   135
        catcher respondTo:#keyPress:x:y:view:
1752
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   136
                    with:[:key :x :y :view | Transcript showCR:'caught return'].
144
claus
parents: 142
diff changeset
   137
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   138
        top := StandardSystemView new.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   139
        top extent:200@200.
144
claus
parents: 142
diff changeset
   140
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   141
        field := EditField in:top.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   142
        field origin:0.0@0.0; width:1.0.
144
claus
parents: 142
diff changeset
   143
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   144
        forwarder := KeyboardForwarder 
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   145
                        to:catcher 
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   146
                        condition:[:type :key :view | (type == #keyPress) & (key == #Return)].
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   147
        field delegate:forwarder.
144
claus
parents: 142
diff changeset
   148
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   149
        top open
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   150
                                                                        [exEnd]
144
claus
parents: 142
diff changeset
   151
claus
parents: 142
diff changeset
   152
claus
parents: 142
diff changeset
   153
    catch all of an enterfields input and ignore it:
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   154
                                                                        [exBegin]
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   155
        |top field forwarder|
144
claus
parents: 142
diff changeset
   156
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   157
        top := StandardSystemView new.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   158
        top extent:200@200.
144
claus
parents: 142
diff changeset
   159
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   160
        field := EditField in:top.
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   161
        field origin:0.0@0.0; width:1.0.
144
claus
parents: 142
diff changeset
   162
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   163
        forwarder := KeyboardForwarder to:nil. 
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   164
        field delegate:forwarder.
144
claus
parents: 142
diff changeset
   165
620
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   166
        top open
c840b7106a64 examples
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   167
                                                                        [exEnd]
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   168
"
9c2378152500 Initial revision
claus
parents:
diff changeset
   169
! !
9c2378152500 Initial revision
claus
parents:
diff changeset
   170
9c2378152500 Initial revision
claus
parents:
diff changeset
   171
!KeyboardForwarder class methodsFor:'instance creation'!
9c2378152500 Initial revision
claus
parents:
diff changeset
   172
139
claus
parents: 134
diff changeset
   173
from:sourceView to:destination
claus
parents: 134
diff changeset
   174
    "create and return a new KeyboardForwarder to redirect key events
claus
parents: 134
diff changeset
   175
     for sourceView to destination. Events from other than the sourceView
claus
parents: 134
diff changeset
   176
     will not be forwarded. The forwarded event will be reported including
claus
parents: 134
diff changeset
   177
     the original view as argument (i.e. as #keyPress:x:y:view:). 
claus
parents: 134
diff changeset
   178
     Use this, if the destination is not a view."
claus
parents: 134
diff changeset
   179
claus
parents: 134
diff changeset
   180
    ^ self new sourceView:sourceView; destination:destination
claus
parents: 134
diff changeset
   181
!
claus
parents: 134
diff changeset
   182
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   183
from:sourceView toView:destinationView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   184
    "create and return a new KeyboardForwarder to redirect key events
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   185
     for sourceView to destinationView. Events from other than the sourceView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   186
     will not be forwarded. The forwarded event will be reported excluding
139
claus
parents: 134
diff changeset
   187
     the original view as argument (i.e. as #keyPress:x:y:). 
claus
parents: 134
diff changeset
   188
     Use this, if the destination is a view."
claus
parents: 134
diff changeset
   189
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   190
    ^ self new sourceView:sourceView; destinationView:destinationView
134
claus
parents: 128
diff changeset
   191
!
claus
parents: 128
diff changeset
   192
139
claus
parents: 134
diff changeset
   193
to:destination
claus
parents: 134
diff changeset
   194
    "create and return a new KeyboardForwarder to redirect any key event
claus
parents: 134
diff changeset
   195
     to destination (Independent of the view in which the event originally
claus
parents: 134
diff changeset
   196
     occurred). The forwarded event will be reported including
claus
parents: 134
diff changeset
   197
     the original view as argument (i.e. as #keyPress:x:y:view:). 
claus
parents: 134
diff changeset
   198
     Use this, if the destination is not a view."
claus
parents: 134
diff changeset
   199
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   200
    ^ self to:destination condition:nil filter:nil 
139
claus
parents: 134
diff changeset
   201
!
claus
parents: 134
diff changeset
   202
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   203
to:destination condition:aCondition
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   204
    "create and return a new KeyboardForwarder to redirect any key event
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   205
     to destinationView (Independent of the view in which the event originally
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   206
     occurred) but only, if some condition as specified by aCondition
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   207
     is met. The forwarded event will be reported including
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   208
     the original view as argument (i.e. as #keyPress:x:y:view:). 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   209
     Use this, if the destination is not a view."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   210
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   211
    ^ self to:destination condition:aCondition filter:nil 
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   212
!
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   213
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   214
to:destination condition:aCondition filter:aFilterBlock
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   215
    "create and return a new KeyboardForwarder to redirect any key event
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   216
     to destinationView (Independent of the view in which the event originally
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   217
     occurred) but only, if some condition as specified by aCondition
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   218
     is met and aFilterBlock returns true for that key.
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   219
     The forwarded event will be reported including
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   220
     the original view as argument (i.e. as #keyPress:x:y:view:). 
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   221
     Use this, if the destination is not a view."
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   222
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   223
    ^ self new destination:destination; condition:aCondition; filter:aFilterBlock
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   224
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   225
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   226
toView:destinationView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   227
    "create and return a new KeyboardForwarder to redirect any key event
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   228
     to destinationView (Independent of the view in which the event originally
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   229
     occurred). The forwarded event will be reported excluding
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   230
     the original view as argument (i.e. as #keyPress:x:y:). 
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   231
     Use this, if the destination is a view."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   232
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   233
    ^ self toView:destinationView condition:nil filter:nil 
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   234
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   235
144
claus
parents: 142
diff changeset
   236
toView:destinationView condition:aCondition
139
claus
parents: 134
diff changeset
   237
    "create and return a new KeyboardForwarder to redirect any key event
claus
parents: 134
diff changeset
   238
     to destinationView (Independent of the view in which the event originally
144
claus
parents: 142
diff changeset
   239
     occurred) but only, if some condition as specified by aCondition
139
claus
parents: 134
diff changeset
   240
     is met. The forwarded event will be reported excluding
claus
parents: 134
diff changeset
   241
     the original view as argument (i.e. as #keyPress:x:y:). 
claus
parents: 134
diff changeset
   242
     Use this, if the destination is a view."
claus
parents: 134
diff changeset
   243
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   244
    ^ self toView:destinationView condition:aCondition filter:nil 
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   245
!
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   246
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   247
toView:destinationView condition:aCondition filter:aFilterBlock
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   248
    "create and return a new KeyboardForwarder to redirect any key event
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   249
     to destinationView (Independent of the view in which the event originally
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   250
     occurred) but only, if some condition as specified by aCondition
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   251
     is met and aFilterBlock returns true for that key.
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   252
     The forwarded event will be reported excluding
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   253
     the original view as argument (i.e. as #keyPress:x:y:). 
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   254
     Use this, if the destination is a view."
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   255
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   256
    ^ self new destinationView:destinationView; condition:aCondition; filter:aFilterBlock
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   257
! !
9c2378152500 Initial revision
claus
parents:
diff changeset
   258
144
claus
parents: 142
diff changeset
   259
!KeyboardForwarder methodsFor:'accessing'!
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   260
134
claus
parents: 128
diff changeset
   261
condition:aCondition
144
claus
parents: 142
diff changeset
   262
    "set the condition - typically a block"
claus
parents: 142
diff changeset
   263
134
claus
parents: 128
diff changeset
   264
    condition := aCondition
claus
parents: 128
diff changeset
   265
!
claus
parents: 128
diff changeset
   266
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   267
destination
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   268
    "return the destination"
144
claus
parents: 142
diff changeset
   269
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   270
    ^ destination
139
claus
parents: 134
diff changeset
   271
!
claus
parents: 134
diff changeset
   272
claus
parents: 134
diff changeset
   273
destination:anObject 
144
claus
parents: 142
diff changeset
   274
    "set the destination 
claus
parents: 142
diff changeset
   275
     - that one will get the event with an additional view arg."
claus
parents: 142
diff changeset
   276
139
claus
parents: 134
diff changeset
   277
    destination := anObject
claus
parents: 134
diff changeset
   278
!
claus
parents: 134
diff changeset
   279
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   280
destinationView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   281
    "return the destination view"
144
claus
parents: 142
diff changeset
   282
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   283
    ^ destinationView
139
claus
parents: 134
diff changeset
   284
!
claus
parents: 134
diff changeset
   285
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   286
destinationView:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   287
    "set the destination view"
144
claus
parents: 142
diff changeset
   288
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   289
    destinationView := aView
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   290
!
9c2378152500 Initial revision
claus
parents:
diff changeset
   291
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   292
filter:aOneArgBlock
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   293
    "set the filter - if non-nil, only keys for which it returns true are forwarded"
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   294
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   295
     filter := aOneArgBlock
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   296
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   297
    "Created: 4.2.1996 / 20:35:15 / cg"
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   298
!
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   299
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   300
sourceView
144
claus
parents: 142
diff changeset
   301
    "get the sourceView - if nonNil, only events from this view will be forwarded"
claus
parents: 142
diff changeset
   302
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   303
    ^ sourceView
142
claus
parents: 140
diff changeset
   304
!
claus
parents: 140
diff changeset
   305
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   306
sourceView:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   307
    "set the sourceView - if nonNil, only events from this view will be forwarded"
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   308
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   309
    sourceView := aView
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   310
! !
9c2378152500 Initial revision
claus
parents:
diff changeset
   311
9c2378152500 Initial revision
claus
parents:
diff changeset
   312
!KeyboardForwarder methodsFor:'event forwarding'!
9c2378152500 Initial revision
claus
parents:
diff changeset
   313
9c2378152500 Initial revision
claus
parents:
diff changeset
   314
keyPress:key x:x y:y view:aView
139
claus
parents: 134
diff changeset
   315
    "handle a delegated event - this is sent by the sensor to actually
claus
parents: 134
diff changeset
   316
     forward the event (i.e. after I returned true on handlesKeyPress:.
claus
parents: 134
diff changeset
   317
     Take care of cyclic delegation (via a kludge-test for negative coordinate)."
claus
parents: 134
diff changeset
   318
3094
7ef0f53288bc always use the new #dispatchEvent methods
ca
parents: 2506
diff changeset
   319
    |xDel yDel forwardedEvent|
1967
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   320
490
1d2ed059a063 delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   321
    x isNil ifTrue:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   322
        "
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   323
         already delegated ... ignore
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   324
        "
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   325
        ^ self
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   326
    ].
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   327
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   328
    filter notNil ifTrue:[
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   329
        (filter value:key) ifFalse:[^ self].
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   330
    ].
9c2378152500 Initial revision
claus
parents:
diff changeset
   331
1967
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   332
    xDel := x.
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   333
    yDel := y.
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   334
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   335
    x == 0 ifTrue:[
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   336
        "
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   337
         already delegated ... care to not delegate twice
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   338
        "
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   339
        xDel := nil.
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   340
        yDel := nil.
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   341
    ].
4aea1cea284e care for recursive redelegation
Claus Gittinger <cg@exept.de>
parents: 1941
diff changeset
   342
139
claus
parents: 134
diff changeset
   343
    destination notNil ifTrue:[
490
1d2ed059a063 delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   344
        destination keyPress:key x:nil y:nil view:aView.
139
claus
parents: 134
diff changeset
   345
    ] ifFalse:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   346
        destinationView notNil ifTrue:[
3682
d756fdb95712 evenTypes - private to windowEvent
ca
parents: 3094
diff changeset
   347
            forwardedEvent := WindowEvent keyPress:key x:xDel y:yDel view:destinationView.
2126
1f108c76dfdb moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   348
            destinationView
3094
7ef0f53288bc always use the new #dispatchEvent methods
ca
parents: 2506
diff changeset
   349
                dispatchEvent:forwardedEvent
693
ed557e02b378 dont redelegate delegated messages
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   350
                withFocusOn:nil 
ed557e02b378 dont redelegate delegated messages
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   351
                delegate:false
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   352
        ]
139
claus
parents: 134
diff changeset
   353
    ]
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   354
2126
1f108c76dfdb moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   355
    "Modified: / 20.5.1998 / 22:54:05 / cg"
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   356
!
9c2378152500 Initial revision
claus
parents:
diff changeset
   357
9c2378152500 Initial revision
claus
parents:
diff changeset
   358
keyRelease:key x:x y:y view:aView
139
claus
parents: 134
diff changeset
   359
    "handle a delegated event - this is sent by the sensor to actually
claus
parents: 134
diff changeset
   360
     forward the event (i.e. after I returned true on handlesKeyRelease:.
claus
parents: 134
diff changeset
   361
     Take care of cyclic delegation (via a kludge-test for negative coordinate)."
claus
parents: 134
diff changeset
   362
3094
7ef0f53288bc always use the new #dispatchEvent methods
ca
parents: 2506
diff changeset
   363
    |forwardedEvent|
7ef0f53288bc always use the new #dispatchEvent methods
ca
parents: 2506
diff changeset
   364
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   365
    x < 0 ifTrue:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   366
        "
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   367
         already delegated ... ignore
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   368
        "
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   369
        ^ self
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   370
    ].
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   371
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   372
    filter notNil ifTrue:[
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   373
        (filter value:key) ifFalse:[^ self].
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   374
    ].
9c2378152500 Initial revision
claus
parents:
diff changeset
   375
139
claus
parents: 134
diff changeset
   376
    destination notNil ifTrue:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   377
        destination keyRelease:key x:-1 y:-1 view:aView
139
claus
parents: 134
diff changeset
   378
    ] ifFalse:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   379
        destinationView notNil ifTrue:[
3682
d756fdb95712 evenTypes - private to windowEvent
ca
parents: 3094
diff changeset
   380
            forwardedEvent := WindowEvent keyRelease:key x:-1 y:-1 view:destinationView.
d756fdb95712 evenTypes - private to windowEvent
ca
parents: 3094
diff changeset
   381
            destinationView dispatchEvent:forwardedEvent withFocusOn:nil delegate:false
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   382
        ]
139
claus
parents: 134
diff changeset
   383
    ]
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   384
2126
1f108c76dfdb moved event dispatching code to view (where it belongs)
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   385
    "Modified: / 20.5.1998 / 22:54:32 / cg"
128
9c2378152500 Initial revision
claus
parents:
diff changeset
   386
! !
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   387
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   388
!KeyboardForwarder methodsFor:'focus forwarding'!
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   389
2506
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   390
hasKeyboardFocus:aBoolean
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   391
    "forward focus information to my destination"
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   392
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   393
    destinationView notNil ifTrue:[
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   394
        destinationView hasKeyboardFocus:aBoolean
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   395
    ].
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   396
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   397
    "Modified: 25.2.1997 / 23:16:35 / cg"
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   398
!
221b75206a75 focus handling changed.
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
   399
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   400
showFocus:explicit
1380
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   401
    "forward focus information to my destination"
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   402
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   403
    |d|
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   404
1380
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   405
    destinationView notNil ifTrue:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   406
        d := destinationView
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   407
    ] ifFalse:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   408
        d := destination
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   409
    ].
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   410
    d notNil ifTrue:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   411
        d showFocus:explicit
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   412
    ]
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   413
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   414
    "Modified: 25.2.1997 / 23:16:35 / cg"
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   415
!
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   416
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   417
showNoFocus:explicit
1380
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   418
    "forward focus information to my destination"
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   419
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   420
    |d|
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   421
1380
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   422
    destinationView notNil ifTrue:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   423
        d := destinationView
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   424
    ] ifFalse:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   425
        d := destination
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   426
    ].
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   427
    d notNil ifTrue:[
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   428
        d showNoFocus:explicit
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   429
    ]
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   430
febf152d630f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
   431
    "Modified: 25.2.1997 / 23:16:40 / cg"
385
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   432
! !
15fd1c806d2a pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   433
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   434
!KeyboardForwarder methodsFor:'queries'!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   435
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   436
checkCondition:type key:key view:aView
1941
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   437
    "return true, if I am interested in an event with type (#keyPress or
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   438
     #keyRelease) and key for aView."
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   439
1693
66ca1549dd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1380
diff changeset
   440
    |wg|
66ca1549dd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1380
diff changeset
   441
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   442
    filter notNil ifTrue:[
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   443
        (filter value:key) ifFalse:[^ false].
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   444
    ].
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   445
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   446
    condition notNil ifTrue:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   447
        condition == #noFocus ifTrue:[
1941
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   448
            wg := aView windowGroup.
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   449
            (wg isNil or:[wg focusView notNil]) ifTrue:[^ false]
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   450
        ].
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   451
        condition isBlock ifTrue:[
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   452
            (condition value:type value:key value:aView) ifFalse:[^ false]
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   453
        ]
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   454
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   455
    sourceView notNil ifTrue:[
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   456
        ^ aView == sourceView
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   457
    ].
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   458
    ^ true
400
47fa508fd78b added optional filterBlock
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   459
1941
0141f373c69c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1752
diff changeset
   460
    "Modified: / 31.10.1997 / 20:24:42 / cg"
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   461
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   462
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   463
delegatesTo:someone
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   464
    "return true, if I delegate events to someone"
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   465
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   466
    ^ destination == someone or:[destinationView == someone]
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   467
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   468
6352
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   469
handlesButtonMotion:something inView:aView
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   470
    "I am not interested in button events"
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   471
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   472
    ^ false
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   473
!
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   474
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   475
handlesButtonPress:something inView:aView
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   476
    "I am not interested in button events"
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   477
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   478
    ^ false
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   479
!
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   480
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   481
handlesKeyPress:key inView:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   482
    "this is the query from the sensor to ask me if I would like to
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   483
     get a keyPress event for key from aView. Return true, if I want so,
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   484
     false otherwise."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   485
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   486
    ^ self checkCondition:#keyPress key:key view:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   487
!
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   488
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   489
handlesKeyRelease:key inView:aView
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   490
    "this is the query from the sensor to ask me if I would like to
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   491
     get a keyRelease event for key from aView. Return true, if I want so,
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   492
     false otherwise."
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   493
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   494
    ^ self checkCondition:#keyRelease key:key view:aView
6352
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   495
!
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   496
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   497
handlesPointerEnter:something inView:aView
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   498
    "I am not interested in pointer events"
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   499
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   500
    ^ false
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   501
!
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   502
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   503
handlesPointerLeave:something inView:aView
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   504
    "I am not interested in pointer events"
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   505
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   506
    ^ false
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   507
! !
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   508
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   509
!KeyboardForwarder class methodsFor:'documentation'!
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   510
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   511
version
7660
7541edd3ab40 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   512
    ^ '$Header$'
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   513
! !
6352
7db661989259 class: KeyboardForwarder
Stefan Vogel <sv@exept.de>
parents: 5277
diff changeset
   514