[prev in list] [next in list] [prev in thread] [next in thread] 

List:       olpc-etoys
Subject:    Re: [etoys-dev] programming etoys itself
From:       Bert Freudenberg <bert () freudenbergs ! de>
Date:       2010-04-23 17:30:29
Message-ID: 48BB8CA4-1A7A-4526-B3B7-DB1192E33114 () freudenbergs ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 22.04.2010, at 17:59, Ricardo Moran wrote:
> Someone more experienced may give you a better help, but I'll give it a try.
> 
> AFAIK there is no good documentation of how to make tiles and stuff (at least I \
> couldn't find anything really useful). I learned most of this stuff by watching \
> examples... the image is full of them ;).  Making an object scriptable is not as \
> easy as it should be because Etoys has a lot of quirks that need some special \
> attention. 
> The tiles are created as slots/commands in the #additionsToViewerCategories method \
> in the class side of the Morph (IMO you can see some simple examples by watching \
> the source code of BookMorph or JoystickMorph). To implement that method correctly \
> you have to be very careful and obey the rules. Below is a simple example: 
> additionsToViewerCategories
> ^ 
> #(
> (#category 
> (
> (#slot #slotName 'comment' #SlotType #readWrite #Player #getterMethod #Player \
> #setterMethod:) (#command #commandName 'comment')
> (#command #commandWithOneParameter: 'comment' #ParameterType)
> )
> )
> )
> 
> The #category must be lowercase (this is one of Etoys quirks I tell you before), \
> otherwise it will not appear... don't ask me why... The #SlotType and \
> #ParameterType are usually Number but they can be Boolean, Color, Point, String, \
> among others... The #readWrite part can also be #readOnly or #writeOnly (I don't \
> know the purpose of the latter, though). The #getterMethod and #setterMethods: are \
> the names of the methods you'll have to implement in order to access the value of \
> the slot. This methods must be implemented in a Player subclass (or Player itself \
> but I don't like to touch the Player class, it's already bloated and messy). If you \
> make a subclass of Player you must implement a method called #newPlayerInstance in \
> your Morph. This method should look like this: 
> newPlayerInstance
> 	^ MySubclassOfPlayer newUserInstance.
> 
> Well, if you have any question don't be afraid to ask. Also it could be a good \
> example to watch the stuff I'm doing as part of the GSoC program. More info here: \
> http://www.pcs.cnu.edu/~rcaton/ESUG/ESUG.html 
> Best regards
> Richo

I also just found this old comment:

Package:		FlexibleVocabularies-nk
Date:			12 October 2003
Author:			Ned Konz

This makes it possible for packages to extend Morph class vocabularies.
Previously, you'd have to edit #additionsToViewerCategories, which would result in \
potential conflicts between different packages that all wanted to (for instance) \
extend Morph's vocabulary.

Subclasses that have additions can do one or both of:
	- override #additionsToViewerCategories (as before)
	- define one or more additionToViewerCategory* methods.

The advantage of the latter technique is that class extensions may be added
by external packages without having to re-define additionsToViewerCategories.

So, for instance, package A could add a method named \
#additionsToViewerCategoryPackageABasic and its methods would be added to the \
vocabulary automatically.


- Bert -


[Attachment #5 (unknown)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; "><div><div>On 22.04.2010, at 17:59, Ricardo \
Moran wrote:</div><blockquote type="cite">Someone more experienced may give you a \
better help, but I'll give it a try.<div><br></div><div><span \
class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; \
border-collapse: collapse; "><div>AFAIK there is no good documentation of how to make \
tiles and stuff (at least I couldn't find anything really useful). I learned most of \
this stuff by watching examples... the image is full of them ;).&nbsp;</div>

<div>Making an object scriptable is not as easy as it should be because Etoys has a \
lot of quirks that need some special attention.</div><div><br></div><div>The tiles \
are created as slots/commands in the #additionsToViewerCategories method in the class \
side of the Morph (IMO you can see some simple examples by watching the source code \
of BookMorph or JoystickMorph). To implement that method correctly you have to be \
very careful and obey the rules. Below is a simple example:</div>

<div><br></div><div><div>additionsToViewerCategories</div><div>^&nbsp;</div><div>#(</div><div>&nbsp;&nbsp; \
&nbsp;(#category&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; \
&nbsp;(</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(#slot #slotName \
'comment' #SlotType #readWrite #Player #getterMethod #Player #setterMethod:)</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(#command #commandName \
'comment')</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(#command \
#commandWithOneParameter: 'comment' #ParameterType)</div><div>&nbsp;&nbsp; &nbsp; \
&nbsp; &nbsp;)</div><div>&nbsp;&nbsp; &nbsp;)</div><div>)</div></div><div><br></div>

<div>The #category must be lowercase (this is one of Etoys quirks I tell you before), \
otherwise it will not appear... don't ask me why...</div><div>The #SlotType and \
#ParameterType are usually Number but they can be Boolean, Color, Point, String, \
among others...</div>

<div>The #readWrite part can also be #readOnly or #writeOnly (I don't know the \
purpose of the latter, though).</div><div>The #getterMethod and #setterMethods: are \
the names of the methods you'll have to implement in order to access the value of the \
slot. This methods must be implemented in a Player subclass (or Player itself but I \
don't like to touch the Player class, it's already bloated and messy). If you make a \
subclass of Player you must implement a method called #newPlayerInstance in your \
Morph. This method should look like this:</div>

<div><br></div><div><div>newPlayerInstance</div><div><span style="white-space: pre; \
">	</span>^ MySubclassOfPlayer newUserInstance.</div></div><div><br></div><div>Well, \
if you have any question don't be afraid to ask. Also it could be a good example to \
watch the stuff I'm doing as part of the GSoC program. More info here:&nbsp;<a \
href="http://www.pcs.cnu.edu/~rcaton/ESUG/ESUG.html">http://www.pcs.cnu.edu/~rcaton/ESUG/ESUG.html</a></div>


<div><br></div><div>Best \
regards</div><div>Richo</div></span></div></blockquote><div><br></div><div>I also \
just found this old comment:</div></div><div><br></div><div><div>Package:<span \
class="Apple-tab-span" \
style="white-space:pre">		</span>FlexibleVocabularies-nk</div><div>Date:<span \
class="Apple-tab-span" style="white-space:pre">			</span>12 October \
2003</div><div>Author:<span class="Apple-tab-span" \
style="white-space:pre">			</span>Ned Konz</div><div><br></div><div>This makes it \
possible for packages to extend Morph class vocabularies.</div><div>Previously, you'd \
have to edit #additionsToViewerCategories, which would result in potential conflicts \
between different packages that all wanted to (for instance) extend Morph's \
vocabulary.</div><div><br></div><div>Subclasses that have additions can do one or \
both of:</div><div><span class="Apple-tab-span" style="white-space:pre">	</span>- \
override #additionsToViewerCategories (as before)</div><div><span \
class="Apple-tab-span" style="white-space:pre">	</span>- define one or more \
additionToViewerCategory* methods.</div><div><br></div><div>The advantage of the \
latter technique is that class extensions may be added</div><div>by external packages \
without having to re-define additionsToViewerCategories.</div><div><br></div><div>So, \
for instance, package A could add a method named \
#additionsToViewerCategoryPackageABasic</div><div>and its methods would be added to \
the vocabulary automatically.</div><div><br></div></div><br><div> <span \
class="Apple-style-span" style="font-size: 12px; "><div style="font-family: \
Helvetica; "><span class="Apple-style-span" style="font-family: Helvetica; ">- Bert \
-</span></div><br class="Apple-interchange-newline"></span> </div>
<br></body></html>



_______________________________________________
etoys-dev mailing list
etoys-dev@squeakland.org
http://lists.squeakland.org/mailman/listinfo/etoys-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic