KeyboardProcessor.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Feb 2000 15:35:03 +0100
changeset 1354 0c7e6c83b440
parent 1310 6ea1bca9654c
child 1388 b5ba6f0d434f
permissions -rw-r--r--
copyrights
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
Object subclass:#KeyboardProcessor
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
    18
	instanceVariableNames:'returnIsOKInDialog escapeIsCancelInDialog menuBar
1251
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
    19
		autoAcceptListeners globalAccelerators'
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Interface-Support-UI'
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!KeyboardProcessor class methodsFor:'documentation'!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 1997 by eXept Software AG
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
documentation
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    ST80 compatibility (mimicry) class.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    The class is not completed yet and certainly not bug free.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    Notice: 
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        this class was implemented using protocol information
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
        from alpha testers, literature and by reading public domain code
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        - it may not be complete or compatible to
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        the corresponding ST-80 class. 
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        If you encounter any incompatibilities, please forward a note 
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
1160
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    59
    KeyboardProcessor is going to take over the focus control
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    60
    mechanism (which are currently located in the windowGroup).
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    61
    Currently, it keeps track of inputFields, and allows for
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    62
    a global accept to be forced.
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    63
    This is especially useful with dialogs, where a global accept
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    64
    should be performed on all inputFields, when the OK button
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    65
    is pressed.
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    66
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    [author:]
1160
Claus Gittinger <cg@exept.de>
parents: 1146
diff changeset
    68
        Claus Gittinger
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
! !
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
1310
6ea1bca9654c category renamining
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
    76
!KeyboardProcessor methodsFor:'Compatibility ST80'!
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
keyboardConsumers
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    ^ #()
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "Created: 6.3.1997 / 15:16:32 / cg"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
removeKeyboardReceiver:aController
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    "Created: / 31.10.1997 / 01:56:54 / cg"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
sendKeyboardTo:aController
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    "Created: / 31.10.1997 / 01:57:15 / cg"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
setActive:aWidget
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "Created: 3.3.1997 / 18:31:09 / cg"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!KeyboardProcessor methodsFor:'accessing'!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
1251
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   101
addAccelerator:aKey action:aSelectorOrBlock
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   102
    "add a global accelerator - these are handled even if no corresponding
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   103
     menu shortcut is defined"
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   104
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   105
    globalAccelerators isNil ifTrue:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   106
        globalAccelerators := Dictionary new
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   107
    ].
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   108
    globalAccelerators at:aKey put:aSelectorOrBlock
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   109
!
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   110
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
escapeIsCancelInDialog:aBoolean
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   112
    "set the escapeIsCancel flag.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   113
     If off, Escape is NOT handled as cancel (however, the default is true)"
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   114
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    escapeIsCancelInDialog := aBoolean
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
menuBar
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    "return the value of the instance variable 'menuBar' (automatically generated)"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ^ menuBar!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
menuBar:something
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    "set the value of the instance variable 'menuBar' (automatically generated)"
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    menuBar := something.!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
returnIsOKInDialog:aBoolean
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   129
    "set the returnIsOK flag.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   130
     If off, Return is NOT handled as accept (however, the default is true)"
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   131
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    returnIsOKInDialog := aBoolean
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
! !
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
!KeyboardProcessor methodsFor:'event handling'!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
1135
ee997fc311e2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   138
processEvent:event forModalView:modalTopOrNil
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   139
    "process a key-event; return true, if handled & eaten; false if not.
1251
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   140
     Here, first, we look for a globalAccelerator,
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   141
     then for Return and Escape in modal applications,
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   142
     (which lead to Accept & Cancel resp.)
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   143
     Finally, menu-shortcuts are handled."
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   144
1251
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   145
    |key topView app view action|
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    view := event view.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    event isKeyPressEvent ifTrue:[
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        key := event key.
1135
ee997fc311e2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   151
        topView := modalTopOrNil ? view topView.
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
        app := topView application.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
1251
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   154
        "/ how about global accelerators ?
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   155
        (globalAccelerators notNil
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   156
        and:[(action := globalAccelerators at:key ifAbsent:nil) notNil])
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   157
        ifTrue:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   158
            action isSymbol ifTrue:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   159
                action numArgs == 1 ifTrue:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   160
                    app perform:action with:event
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   161
                ] ifFalse:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   162
                    app perform:action
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   163
                ].
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   164
            ] ifFalse:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   165
                action numArgs == 1 ifTrue:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   166
                    action value:event
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   167
                ] ifFalse:[
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   168
                    action value
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   169
                ]
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   170
            ].
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   171
            ^ true
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   172
        ].
2b4223c2e092 added global accelerator
Claus Gittinger <cg@exept.de>
parents: 1160
diff changeset
   173
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
        topView isModal ifTrue:[
1146
4ae177ac1fd3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   175
            topView windowGroup explicitFocusView isNil ifTrue:[
1134
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   176
                (returnIsOKInDialog and:[key == #Return]) ifTrue:[
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   177
                    self requestGlobalAutoAccept ifFalse:[^ true].
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   178
                    app doAccept.
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   179
                    ^ true
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   180
                ].
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
            ].
1134
758151d73aac only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   182
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
            (escapeIsCancelInDialog and:[key == #Escape]) ifTrue:[
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
                app doCancel.
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   185
                ^ true
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
            ].
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        ].
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        "/ how about menu-shortkeys ?
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        (menuBar notNil and:[(menuBar processShortcutKeyEventInMenuBar:event)]) ifTrue:[
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   191
            ^ true
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        ]
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    ].
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   195
    ^ false
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    "/ let view dispatch it.
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
requestForWindowClose
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   204
     "about to close the window."
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   206
     ^ true
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
requestGlobalAutoAccept
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   210
     "about to close the window via return ok accept.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   211
      Ask all acceptListeners to accept their value and return true, if all of those fields
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   212
      did."
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   214
    autoAcceptListeners notNil ifTrue:[
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   215
        autoAcceptListeners do:[:aListener |
1133
48fe25214e65 fixed requestAutoAccept.
Claus Gittinger <cg@exept.de>
parents: 1131
diff changeset
   216
            (aListener requestAutoAccept) ifFalse:[^ false].
48fe25214e65 fixed requestAutoAccept.
Claus Gittinger <cg@exept.de>
parents: 1131
diff changeset
   217
        ].
48fe25214e65 fixed requestAutoAccept.
Claus Gittinger <cg@exept.de>
parents: 1131
diff changeset
   218
        ^ true
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   219
    ].
1133
48fe25214e65 fixed requestAutoAccept.
Claus Gittinger <cg@exept.de>
parents: 1131
diff changeset
   220
    ^ false
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
! !
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
1128
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   224
!KeyboardProcessor methodsFor:'setup'!
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   225
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   226
addAutoAcceptListener:aListener
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   227
    "add a aListener to my autoAcceptListeners.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   228
     Typically, inputFields add themself, to be notified (via requestForAutoAccept)
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   229
     when the dialog is about to be closed with returnIsOK or accept.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   230
     (of course, other listeners are also invited ;-)"
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   231
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   232
    autoAcceptListeners isNil ifTrue:[
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   233
        autoAcceptListeners := IdentitySet new.
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   234
    ].
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   235
    autoAcceptListeners add:aListener
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   236
! !
7810bca304e3 added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   237
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
!KeyboardProcessor class methodsFor:'documentation'!
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
version
1310
6ea1bca9654c category renamining
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   241
    ^ '$Header: /cvs/stx/stx/libview2/KeyboardProcessor.st,v 1.10 2000-01-17 11:28:50 cg Exp $'
1124
3dc83be3a3f9 moved from libcompat
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
! !