I am indeed on Linux. I have a feeling that Windows was the same (coding in Java). That is, in the programming language a real key down and a repeat are indistinguishable.
Stan
Bert Freudenberg wrote:
On Mar 7, 2008, at 14:54 , stan shepherd wrote:
Where I was confused is that checking if the key is pressed already doesn't appear to differentiate between a 'real' key down and a repeat. For example :
keyDown: anEvent (keys includes: anEvent keyValue) ifTrue: [Transcript show: 'skipped ' , anEvent asString; cr] ifFalse: [keys add: anEvent keyValue. " Transcript show: 'key down ' , anEvent asString; cr. self changed]
always takes the 'key down' branch, even for key held down.
Was this what you meant?
Yes. The code above works as expected on Mac OS X, printing "skipped..." for auto-repeats.
On the other hand, looping over this in a thread:
keyStrokes keys do: [:key | key ifNotNil: [(oldKeys includes: key) ifFalse: [Transcript show: 'key added ' , key asString; cr]]]. oldKeys do: [:key | key ifNotNil: [(keys includes: key) ifFalse: [Transcript show: 'key removed ' , key asString; cr]]]. oldKeys := keys copy.
has the desired effect of only showing real key moves.
Is this over complicating things?
It indeed sounds overly complicated, unless your platform forces you to resort to such things. Are you on Linux by chance?
- Bert -
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners