[Newbies] I am a total beginner with some questions

Marcus Strehlow marcus.strehlow at gmail.com
Tue Apr 8 15:53:12 UTC 2008

Hi there,

As mentioned before, your class would have to inherit the method
handleKeytroke:, keyStroke: and keyDown: inside which you then decide what
should be done. However, in order to find out which key has been pressed,
you will have to find out the corresponding ASCII code, and then check if
the pressed ASCII code is the same as the one you want to monitor.

x := Sensor keyboardPeek asciiValue.
(x == 99) "99 is the ascii value for the letter c"
ifTrue: [Transcript show: 'letter c was pressed'; cr].

If this is implemented in the keyDown: method, everytime the c key is
pressed, the Transcript should show the text specified.

You can find the ASCII values for each key on www.asciitable.com . In the
image on the page, the ASCII value is the one in the Dec column.

Displaying an image is fairly easy, as long as Squeak supports the format.
Current supported formats are GIF, JPG, PNG and BMP if I remember correctly.
To use an image inside any morph or in the world, use this:

x := ImageMorph new.
x image: (Form fromFileNamed: 'path/to/your/image.jpg').
x openInWorld.

This will load the specified file, create the necessary form, and is then
opened in your current world.

I hope this helps a bit,


> Message: 1
> Date: Mon, 7 Apr 2008 14:44:32 -0700 (PDT)
> From: kennellgr <cboneg5 at gmail.com>
> Subject: [Newbies] I am a total beginner with some questions
> To: beginners at lists.squeakfoundation.org
> Message-ID: <16540965.post at talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii

> I really like programming (I've done some in C) and I decided I wanted to
> doing some programming on my Mac. I spent hours online trying to find
> something that I could learn and settled on Squeak. I have it and barely
> understand the basics of it.

> A few Questions:

> 1. What do I do to test whether or not a key has been pressed (in a method
> want it to say 'if C key is pressed down do this')

> 2. What do I do to display a picture that I have on my computer?

iMac -- 20 inch -- Core 2, 2 GHz -- 1 GB RAM -- Superdrive -- Mac OS X
Leopard 10.5.2
MacBook -- 13.3 inch -- Core 2, 1.83 GHz -- 1.5 GB RAM -- Combodrive -- Mac
OS X Leopard 10.5.2
iMac G5 -- 17 inch -- PPC G5 1.8 GHz -- 1 GB RAM -- Superdrive -- Mac OS X
Leopard 10.5.2
iPod touch -- 16 GB -- Software Upgrade -- iPhone OS 1.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080408/eca74466/attachment.htm

More information about the Beginners mailing list