[Squeakland] 2 questions - embedding text box and keystroke
listener
Ned Konz
ned at squeakland.org
Mon Dec 13 18:39:24 PST 2004
On Sunday 12 December 2004 7:55 am, Alan Kay wrote:
> Perhaps Scott or Ned can tell us about the current state of keyboard
> listening in the etoy system (the feature is there but turned off, again
> for good reasons).
Actually, it's broken right now. I have sent Michael a fix.
There are two parts:
* The World has a String-valued property called 'lastKeystroke'. This is a
string that holds the keystroke, in a form that can be used in string
comparisons, like:
'a'
'<left>'
'<Ctrl-left>'
This works OK now; you can have a ticking script (for instance) testing the
lastKeystroke property. But you may very well miss one, unless you use the
other part:
* You can trigger a script that is owned by the World on a 'keyStroke' event.
You do this by clicking on the 'when this script should run' button, and
choosing 'more' and then 'keyStroke'. This is the part that is currently
broken.
The attached change set fixes this problem, if you want to experiment with it
and know what to do with change sets. Otherwise, you will have to wait for
the fix to appear as a Squeakland update.
Anyway, with these two features you can do something like the script pictured
in the attached image, which moves a Rectangle around by keyboard command.
--
Ned Konz
http://bike-nomad.com/squeak/
-------------- next part --------------
'From Squeakland 3.8.5976 of 25 August 2004 [latest update: #371] on 13 December 2004 at 6:25:18 pm'!
"Change Set: EnableKeystrokeEvent-nk
Date: 13 December 2004
Author: Ned Konz
CS 0359keyboardEvents-nk did not register the keystroke event trigger properly (or rather, 0367specificEvents-nk didn't change PasteUpMorph>>initialize as it should).
This change set restores the 'keyStroke' event for PasteUpMorphs including the World.
"!
!PasteUpMorph class methodsFor: 'class initialization' stamp: 'nk 12/13/2004 18:22'!
initialize
"Initialize the class"
self registerInFlapsRegistry.
ScriptingSystem addCustomEventFor: self named: #keyStroke help: 'when a keystroke happens and nobody heard it' targetMorphClass: PasteUpMorph.! !
PasteUpMorph initialize!
"Postscript:
Now make sure that PasteUpMorph is properly registered."
PasteUpMorph initialize.
!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MoveRectangleByKeystrokes.png
Type: image/png
Size: 17973 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20041213/bef940eb/MoveRectangleByKeystrokes-0001.png
More information about the Squeakland
mailing list