InputSensor kbdTest
Bob Arning
arning at charm.net
Mon May 28 11:22:43 UTC 2001
Bert,
The problem is that
processKeyboardEvent: evt
"Never update keyboardBuffer if we have an eventQueue active"
and kbdTest utlimately depends on the keyboardBuffer. Here is a version that seems to work in Morphic.
Cheers,
Bob
=====
'From Squeak3.1alpha of 5 February 2001 [latest update: #4089] on 28 May 2001 at 7:18:36 am'!
"Change Set: kbdTest
Date: 28 May 2001
Author: Bob Arning
A version of #kbdTest that works in Morphic"!
!EventSensor methodsFor: 'keyboard' stamp: 'RAA 5/28/2001 07:17'!
kbdTest "Sensor kbdTest"
"This test routine will print the unmodified character, its keycode,
and the OR of all its modifier bits, until the character x is typed"
| char evt type pressCode charCode |
[
char _ nil.
inputSemaphore signal.
eventQueue ifNil: [
keyboardBuffer peek ifNotNil: [
char _ self characterForKeycode: self keyboard.
mouseButtons _ self primMouseButtons.
].
] ifNotNil: [
(evt _ eventQueue nextOrNil) ifNotNil: [
type _ evt at: 1.
EventTypeMouse = type ifTrue: [self processMouseEvent: evt].
EventTypeKeyboard = type ifTrue: [
pressCode _ evt at: 4.
pressCode = EventKeyChar ifTrue: [
charCode _ evt at: 3.
charCode ifNil: [^self].
mouseButtons _ (mouseButtons bitAnd: 7) bitOr: ((evt at: 5) bitShift: 3).
char _ Character value: charCode.
].
].
].
].
char ifNotNil: [
{char. char asciiValue. char asciiValue radix: 16. mouseButtons} printString,
' ' displayAt: 10 at 10.
].
char = $x
] whileFalse! !
=====
On Mon, 28 May 2001 11:48:45 +0200 (CEST) Bert Freudenberg <bert at isg.cs.uni-magdeburg.de> wrote:
>On Wed, 23 May 2001, Bob Arning wrote:
>
>> On Wed, 23 May 2001 18:12:02 -0700 (PDT) doug edmunds <being_doug at yahoo.com> wrote:
>> >That's what I had tried, but apparently from
>> >within Morphic. This leads to the question,
>> >why would this work in MVC but not Morphic?
>>
>> It stems from a rework of the event handling mechanisms.
>
>But the EventSensor tries to be compatible whit the InputSensor. Looking
>at the code I see no reason why it should not work.
>
> InputSensor>>kbdTest
> InputSensor>>keyboardPressed
> EventSensor>>primKbdPeek
> inputSemaphore signal
> EventSensor>>ioProcess
> primGetNextEvent
>
>Is it possible the ioProcess is not run immediately when the signal is
>raised?
More information about the Squeak-dev
mailing list
|