[Newbies] I am a total beginner with some questions

kennellgr cboneg5 at gmail.com
Wed Apr 9 00:38:26 UTC 2008


Hi,

I appreciate the help. I tried it out and it works. I have one problem
though. I created a method called "gdkDKeyDown" (gdk is my innitials so I
put it before my methods) and when I type gdkDKeyDown in a workspace and
print it it says nil (it's supposed to say true or false) how do I make it
return a value?

This is the method:


gdkDKeyDown
	| x |
	x := Sensor keyboardPeek asciiValue.
	x == 99
		ifTrue: [^ true].
	^ false



Marcus Strehlow wrote:
> 
> 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,
> 
> Marcus
> 
> 
> 
>> 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
> try
>> 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
> I
>> 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
> 
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 

-- 
View this message in context: http://www.nabble.com/I-am-a-total-beginner-with-some-questions-tp16540965p16576999.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.



More information about the Beginners mailing list