"
COPYRIGHT (c) 1995 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.
"
WindowSensor subclass:#SynchronousWindowSensor
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Interface-Support'
!
!SynchronousWindowSensor class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 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
"
in contrast to a regular windowSensor, instances of SynchronousWindowSensor
do NOT put events into a queue and do NOT wakeup any windowGroup process.
Instead, the underlying view is notified synchronously (via a message send)
about the event.
These are used for only one single situation:
when a modal debugger is open
(i.e. one that is debugging the scheduler or event-dispatcher).
This debuggers windowGroup is augmented with a synchronous Sensor, in order
to prevent the event handling code from suspending any process
(you cannot suspend the scheduler; you should not suspend the event dispatcher).
This is pretty tricky and magic - you dont have to understand this.
(consider this system internal code)
These sensors are not used with regular views.
[author:]
Claus Gittinger
"
! !
!SynchronousWindowSensor methodsFor:'event handling'!
buttonMotion:button x:x y:y view:aView
"forward a button-motion for some view"
WindowEvent
sendEvent:#buttonMotion:x:y:
arguments:(Array with:button with:x with:y)
view:aView
"Created: 24.11.1995 / 19:14:02 / cg"
!
buttonMultiPress:button x:x y:y view:aView
"forward a button-multi-press event for some view"
WindowEvent
sendEvent:#buttonMultiPress:x:y:
arguments:(Array with:button with:x with:y)
view:aView
"Created: 24.11.1995 / 19:14:14 / cg"
!
buttonPress:button x:x y:y view:aView
"forward a button-press event for some view"
WindowEvent
sendEvent:#buttonPress:x:y:
arguments:(Array with:button with:x with:y)
view:aView
"Created: 24.11.1995 / 19:14:25 / cg"
!
buttonRelease:button x:x y:y view:aView
"forward a button-release event for some view"
WindowEvent
sendEvent:#buttonRelease:x:y:
arguments:(Array with:button with:x with:y)
view:aView
"Created: 24.11.1995 / 19:14:36 / cg"
!
configureX:x y:y width:w height:h view:aView
"forward a configure for some view"
aView configureX:x y:y width:w height:h
"Created: 24.11.1995 / 19:14:59 / cg"
!
coveredBy:otherView view:aView
"forward a covered for some view"
aView coveredBy:otherView
"Created: 24.11.1995 / 19:15:11 / cg"
!
destroyedView:aView
"forward a destroyed event for some view"
aView destroyed
"Created: 24.11.1995 / 19:15:22 / cg"
!
exposeX:x y:y width:w height:h view:aView
"forward an expose for some view"
"/ this is also a possible response to a scroll operation
"/ (if an expose is pending)
catchExpose == aView ifTrue:[
gotExpose == false ifTrue:[
gotExpose := true.
]
].
WindowEvent
sendEvent:#exposeX:y:width:height:
arguments:(Array with:x with:y with:w with:h)
view:aView
"Created: 24.11.1995 / 19:15:54 / cg"
"Modified: 18.1.1997 / 17:33:09 / cg"
!
focusInView:aView
"forward a focusIn event for some view"
WindowEvent
sendEvent:#focusIn
arguments:nil
view:aView
"Created: 24.11.1995 / 19:16:11 / cg"
!
focusOutView:aView
"forward a focusOut event for some view"
WindowEvent
sendEvent:#focusOut
arguments:nil
view:aView
"Created: 24.11.1995 / 19:16:24 / cg"
!
graphicExposeX:x y:y width:w height:h view:aView
"forward a graphic expose for some view"
"/ this is also a possible response to a scroll operation
"/ (if an expose is pending)
catchExpose == aView ifTrue:[
gotExpose == false ifTrue:[
gotExpose := true.
]
].
WindowEvent
sendEvent:#graphicExposeX:y:width:height:
arguments:(Array with:x with:y with:w with:h)
view:aView
"Created: 24.11.1995 / 19:16:38 / cg"
"Modified: 18.1.1997 / 17:34:01 / cg"
!
keyPress:untranslatedKey x:x y:y view:aView
"forward a key-press event for some view"
|xlatedKey|
self key:untranslatedKey state:true.
xlatedKey := aView graphicsDevice translateKey:untranslatedKey.
xlatedKey notNil ifTrue:[
WindowEvent
sendEvent:#keyPress:x:y:
arguments:(Array with:xlatedKey with:x with:y)
view:aView
]
"Created: 24.11.1995 / 19:17:23 / cg"
"Modified: 28.5.1996 / 20:25:23 / cg"
!
keyRelease:untranslatedKey x:x y:y view:aView
"forward a key-release event for some view"
|xlatedKey|
self key:untranslatedKey state:false.
xlatedKey := aView graphicsDevice translateKey:untranslatedKey.
xlatedKey notNil ifTrue:[
WindowEvent
sendEvent:#keyRelease:x:y:
arguments:(Array with:xlatedKey with:x with:y)
view:aView
]
"Created: 24.11.1995 / 19:17:50 / cg"
"Modified: 28.5.1996 / 20:25:25 / cg"
!
mappedView:aView
"forward a mapped event for some view"
aView mapped
"Created: 24.11.1995 / 19:18:01 / cg"
!
noExposeView:aView
"forward a noExpose event for some view"
catchExpose isNil ifTrue:[
'SWSensor [info]: noExpose but not catching' infoPrintCR.
].
catchExpose := nil.
gotExpose := true.
aView noExpose.
"Created: 24.11.1995 / 19:18:10 / cg"
"Modified: 18.1.1997 / 16:18:42 / cg"
!
pointerEnter:buttonState x:x y:y view:aView
"forward a pointer enter for some view"
WindowEvent
sendEvent:#pointerEnter:x:y:
arguments:(Array with:buttonState with:x with:y)
view:aView
"Created: 24.11.1995 / 19:18:20 / cg"
!
pointerLeave:buttonState view:aView
"forward a pointer leave for some view"
WindowEvent
sendEvent:#pointerLeave:
arguments:(Array with:buttonState)
view:aView
"Created: 24.11.1995 / 19:18:30 / cg"
!
saveAndTerminateView:aView
"forward a saveAndTerminate event for some view"
aView saveAndTerminate
"Created: 24.11.1995 / 19:18:38 / cg"
!
terminateView:aView
"forward a terminate event for some view"
aView terminate
"Created: 24.11.1995 / 19:18:48 / cg"
!
unmappedView:aView
"forward an unmapped event for some view"
aView unmapped
"Created: 24.11.1995 / 19:18:59 / cg"
! !
!SynchronousWindowSensor methodsFor:'specials'!
catchExposeFor:aView
"start catching noExpose events (must be done BEFORE a bitblt)."
catchExpose notNil ifTrue:[
'WSensor [warning]: already catching in catchExpose' errorPrintCR.
].
gotExpose := false.
gotOtherEvent := false.
catchExpose := aView.
"Created: 18.1.1997 / 15:34:31 / cg"
"Modified: 18.1.1997 / 16:17:32 / cg"
!
waitForExposeFor:aView
"wait until a graphicsExpose or a noExpose arrives (after a bitblt)."
"
cannot suspend, I am a synchronous-modal sensor
"
[gotExpose] whileFalse:[
aView graphicsDevice dispatchExposeEventFor:aView id.
Processor yield.
].
catchExpose := nil
"Created: 24.11.1995 / 20:03:07 / cg"
"Modified: 18.1.1997 / 16:17:39 / cg"
! !
!SynchronousWindowSensor class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview/SynchronousWindowSensor.st,v 1.12 1997-01-18 16:34:15 cg Exp $'
! !