EventMonitor.st
author Claus Gittinger <cg@exept.de>
Tue, 15 Feb 2005 17:36:47 +0100
changeset 6187 ba3bb76a88ff
parent 2805 9fb350d5fef0
child 6344 d5588ae5e92a
permissions -rw-r--r--
handle 16bit chars

"
 COPYRIGHT (c) 1991 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

"{ Package: 'stx:libtool' }"

StandardSystemView subclass:#EventMonitor
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Monitors-ST/X'
!

!EventMonitor class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1991 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    like xev - show events.
    You can use this to check your keyboard mappings, for example.
    start with: 
	EventMonitor open
    and watch the output on xterm.
"
! !

!EventMonitor class methodsFor:'defaults'!

defaultExtent
    ^ 200 @ 200
!

defaultLabel
    ^ 'Event Monitor'
! !

!EventMonitor class methodsFor:'startup'!

isVisualStartable
    ^ true

    "Created: / 10.8.1998 / 16:03:13 / cg"
! !

!EventMonitor methodsFor:'events'!

buttonMotion:state x:x y:y
    'buttonMotion x:' print. x print. ' y:' print. y print.
    ' state:' print. state printCR

    "Modified: 5.4.1997 / 01:23:39 / cg"
!

buttonMultiPress:button x:x y:y
    'buttonMultiPress x:' print. x print. ' y:' print. y print.
    ' button:' print. button printCR

    "Modified: / 5.4.1997 / 01:23:42 / cg"
    "Created: / 19.5.1999 / 09:40:40 / cg"
!

buttonPress:button x:x y:y
    'buttonPress x:' print. x print. ' y:' print. y print.
    ' button:' print. button printCR

    "Modified: 5.4.1997 / 01:23:42 / cg"
!

buttonRelease:button x:x y:y
    'buttonRelease x:' print. x print. ' y:' print. y print.
    ' button:' print. button printCR

    "Modified: 5.4.1997 / 01:23:43 / cg"
!

configureX:x y:y width:newWidth height:newHeight
    'configure x:' print. x print. ' y:' print. y print.
    ' width:' print. newWidth print. ' height:' print. newHeight printCR.

    ^ super configureX:x y:y width:newWidth height:newHeight

    "Modified: 5.4.1997 / 01:23:45 / cg"
!

dropMessage:dropType data:dropData
    'drop: ' print. dropType print. ' data:' print. dropData printCR.

    "Modified: 5.4.1997 / 01:23:28 / cg"
!

focusIn
    'focusIn' printCR.

    "Created: 7.3.1996 / 15:06:18 / cg"
    "Modified: 5.4.1997 / 01:23:48 / cg"
!

focusOut
    'focusOut' printCR.

    "Created: 7.3.1996 / 15:06:21 / cg"
    "Modified: 5.4.1997 / 01:23:49 / cg"
!

hasKeyboardFocus:aBoolen
    'hasKeyboardFocus:' print. aBoolen printCR

    "Modified: / 19.5.1999 / 09:42:59 / cg"
!

keyPress:key x:x y:y
    |s untranslatedKey|

    s := 'KeyPress x:' , x printString , ' y:' , y printString.
    s print.
    Transcript show:s.
    (key isMemberOf:Character) ifTrue:[
        s := ' character key:' , key printString
             , ' (' , key asciiValue printString , ')'.
    ] ifFalse:[
        s := ' symbolic key:' , key storeString.
        untranslatedKey := device keyboardMap keyAtValue:key ifAbsent:key.
        untranslatedKey ~~ key ifTrue:[
            s := s , ' untranslated key:' , untranslatedKey printString
        ].
    ].
    s printCR.
    Transcript showCR:s.
!

keyRelease:key x:x y:y
    |untranslatedKey|

    'KeyRelease x:' print. x print. ' y:' print. y print.
    (key isMemberOf:Character) ifTrue:[
        key codePoint <= 16rFF ifTrue:[
            ' character key:' print. key print.
        ] ifFalse:[
            ' unicode character utf8:' print. key asString utf8Encoded asByteArray hexPrintOn:Stdout.
        ].
        ' (' print. key asciiValue print. ')' print
    ] ifFalse:[
        ' symbolic key:' print. key storeString print.
        untranslatedKey := device keyboardMap keyAtValue:key ifAbsent:key.
        untranslatedKey ~~ key ifTrue:[
            ' untranslated key:' print. untranslatedKey print
        ]
    ].

    '' printCR
!

mapped
    'mapped' printCR.
    super mapped.

    "Modified: / 6.1.1999 / 11:04:32 / cg"
!

pointerEnter:state x:x y:y
    'pointerEnter x:' print. x print. ' y:' print. y print.
    ' state:' print. state printCR

    "Modified: 5.4.1997 / 01:24:02 / cg"
!

pointerLeave:state 
    'pointerLeave state:' print. state printCR

    "Modified: 5.4.1997 / 01:24:05 / cg"
!

unmapped
    'unmapped' printCR.
    super unmapped.

    "Modified: / 6.1.1999 / 11:04:22 / cg"
!

visibilityChange:how
    'visibilityChange:' print. how storeString printCR.
    super visibilityChange:how

    "Modified: / 6.1.1999 / 11:04:12 / cg"
! !

!EventMonitor methodsFor:'initialization'!

initialize
    |l|

    super initialize.

    l := Label label:'see event trace\on standard output' withCRs in:self.
    l borderWidth:0
! !

!EventMonitor methodsFor:'realization'!

initEvents
    self enableMotionEvents.
    self enableKeyReleaseEvents.
    self enableEnterLeaveEvents.
    self enableFocusEvents.
    self enableEvent:#visibilityChange

    "Modified: 7.3.1996 / 15:06:42 / cg"
! !

!EventMonitor class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/EventMonitor.st,v 1.21 2005-02-15 16:36:47 cg Exp $'
! !