[squeak-dev] The Inbox: Kernel-mt.1287.mcz
K K Subbu
kksubbu.ml at gmail.com
Mon Dec 16 14:47:48 UTC 2019
On 16/12/19 3:54 PM, Marcel Taeumel wrote:
> MyMorph >> #handlesKeyboard: evt
> ^ true
> MyMorph >> #keyStroke: evt
> (evt controlKeyPressed and: [evt keyCharacter = $c])
> ifTrue: [self terminateApplication].
>
> Why? Because there might be the requirement to "terminate on ctrl+c" for
> some application and it would be nice if one could just implement it
> that way. :-)
Morphic is a GUI. Its input handler should not have to deal with
host-specific modifiers and just map keycodes to selectors (commands).
VM input plugin will parse CTRL+Q into keycode 16r11 to Squeak. Morphic
input handler will map this keycode to, say, #quitKey. so you should
just be able to write:
MyMorph>>quitKey
self terminateApplication
Later if we want to allow ALT+Q also to quit, then we just need to add a
single entry to the Morphic keycode map.
> But maybe I am confusing "characters" and "keys" again. Happens way too
> quickly.
It happens to me too, especially when working late into the night ;-).
I think of a keycode as a SmallInt (or sequence of SmallInts) that
encodes a Character or Symbol (selector), just like a machine word
encoding integer or oop.
Regards .. Subbu
More information about the Squeak-dev
mailing list
|