KeyboardProcessor.st
changeset 1124 3dc83be3a3f9
child 1128 7810bca304e3
equal deleted inserted replaced
1123:8785a3f23e4b 1124:3dc83be3a3f9
       
     1 "
       
     2  COPYRIGHT (c) 1997 by eXept Software AG
       
     3               All Rights Reserved
       
     4 
       
     5  This software is furnished under a license and may be used
       
     6  only in accordance with the terms of that license and with the
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 
       
    13 
       
    14 
       
    15 
       
    16 
       
    17 Object subclass:#KeyboardProcessor
       
    18 	instanceVariableNames:'returnIsOKInDialog escapeIsCancelInDialog menuBar'
       
    19 	classVariableNames:''
       
    20 	poolDictionaries:''
       
    21 	category:'Interface-Support-UI'
       
    22 !
       
    23 
       
    24 !KeyboardProcessor class methodsFor:'documentation'!
       
    25 
       
    26 copyright
       
    27 "
       
    28  COPYRIGHT (c) 1997 by eXept Software AG
       
    29               All Rights Reserved
       
    30 
       
    31  This software is furnished under a license and may be used
       
    32  only in accordance with the terms of that license and with the
       
    33  inclusion of the above copyright notice.   This software may not
       
    34  be provided or otherwise made available to, or used by, any
       
    35  other person.  No title to or ownership of the software is
       
    36  hereby transferred.
       
    37 "
       
    38 
       
    39 
       
    40 
       
    41 
       
    42 !
       
    43 
       
    44 documentation
       
    45 "
       
    46     ST80 compatibility (mimicry) class.
       
    47 
       
    48     The class is not completed yet and certainly not bug free.
       
    49     Also, it is not guaranteed that all winSpecs are understood.
       
    50 
       
    51     Notice: 
       
    52         this class was implemented using protocol information
       
    53         from alpha testers, literature and by reading public domain code
       
    54         - it may not be complete or compatible to
       
    55         the corresponding ST-80 class. 
       
    56         If you encounter any incompatibilities, please forward a note 
       
    57         describing the incompatibility verbal (i.e. no code) to the ST/X team.
       
    58 
       
    59     [author:]
       
    60         Claus Atzkern
       
    61 "
       
    62 
       
    63 
       
    64 
       
    65 
       
    66 ! !
       
    67 
       
    68 !KeyboardProcessor methodsFor:'ST80 - mimicri'!
       
    69 
       
    70 keyboardConsumers
       
    71     ^ #()
       
    72 
       
    73     "Created: 6.3.1997 / 15:16:32 / cg"
       
    74 !
       
    75 
       
    76 removeKeyboardReceiver:aController
       
    77 
       
    78     "Created: / 31.10.1997 / 01:56:54 / cg"
       
    79 !
       
    80 
       
    81 sendKeyboardTo:aController
       
    82 
       
    83     "Created: / 31.10.1997 / 01:57:15 / cg"
       
    84 !
       
    85 
       
    86 setActive:aWidget
       
    87 
       
    88     "Created: 3.3.1997 / 18:31:09 / cg"
       
    89 ! !
       
    90 
       
    91 !KeyboardProcessor methodsFor:'accessing'!
       
    92 
       
    93 escapeIsCancelInDialog:aBoolean
       
    94     escapeIsCancelInDialog := aBoolean
       
    95 !
       
    96 
       
    97 menuBar
       
    98     "return the value of the instance variable 'menuBar' (automatically generated)"
       
    99 
       
   100     ^ menuBar!
       
   101 
       
   102 menuBar:something
       
   103     "set the value of the instance variable 'menuBar' (automatically generated)"
       
   104 
       
   105     menuBar := something.!
       
   106 
       
   107 returnIsOKInDialog:aBoolean
       
   108     returnIsOKInDialog := aBoolean
       
   109 
       
   110 ! !
       
   111 
       
   112 !KeyboardProcessor methodsFor:'event handling'!
       
   113 
       
   114 processEvent:event
       
   115     |key topView app view|
       
   116 
       
   117     view := event view.
       
   118 
       
   119     event isKeyPressEvent ifTrue:[
       
   120         key := event key.
       
   121         topView := view topView.
       
   122         app := topView application.
       
   123 
       
   124         topView isModal ifTrue:[
       
   125             (returnIsOKInDialog and:[key == #Return]) ifTrue:[
       
   126                 app doAccept.
       
   127                 ^ self
       
   128             ].
       
   129             (escapeIsCancelInDialog and:[key == #Escape]) ifTrue:[
       
   130                 app doCancel.
       
   131                 ^ self
       
   132             ].
       
   133         ].
       
   134 
       
   135         "/ how about menu-shortkeys ?
       
   136         (menuBar notNil and:[(menuBar processShortcutKeyEventInMenuBar:event)]) ifTrue:[
       
   137             ^ self
       
   138         ]
       
   139     ].
       
   140 
       
   141     view dispatchEvent:event
       
   142 
       
   143     "/ let view dispatch it.
       
   144 
       
   145 
       
   146 
       
   147 !
       
   148 
       
   149 requestForWindowClose
       
   150      "about to close the window.
       
   151       If autoAccept is true, check for this, and only return true if all
       
   152       fields agree."
       
   153 
       
   154     ^ self requestGlobalAutoAccept
       
   155 
       
   156 !
       
   157 
       
   158 requestGlobalAutoAccept
       
   159      "about to close the window.
       
   160       If autoAccept is true, check for this, and only return true if all
       
   161       fields agree."
       
   162 
       
   163     ^ true
       
   164 
       
   165 ! !
       
   166 
       
   167 !KeyboardProcessor class methodsFor:'documentation'!
       
   168 
       
   169 version
       
   170     ^ '$Header: /cvs/stx/stx/libview2/KeyboardProcessor.st,v 1.1 1999-03-09 16:40:36 cg Exp $'
       
   171 ! !