[lively-kernel] How to add a property to a morph visually

Milan Zimmermann milan.zimmermann at gmail.com
Sat Feb 11 19:39:05 CET 2012


On Sat, Feb 11, 2012 at 7:18 AM, Roeder, Marko
<Marko.Roeder at student.hpi.uni-potsdam.de> wrote:
> Hi Milan -
>
> Well I was not clear in my question .. "this.pages" must be a
> deserialized Morph, from the xhtml page (or dragged from Parts Bin),
> but, how would I create the "this.pages" list and add to the
> ElProfesorOnLivelyKernel as a member, if I was to create the Profesor
> from scratch …
>
>
> To make it obvious that this attribute has been added to the
> Part/rectangle/... , we sometimes added a script called reset() via the
> ObjectExplorer that simply adds/clears those attributes (you might have to
> look at some Parts to find one that uses reset - but for example the
> PartsBin (Tools -> PartsBinBrowser) does).
>
> So in your case it could be something like this:
>
> this.addScript(function reset() {
>     this.books = [];
> }).tag([]);
>
> Additionally, having defined this script you will also get a menu item
> "reset" (halo item (M)enu) that executes it. In case of the PartsBinBrowser
> for example we use reset() to clear any state before publishing changes back
> to the PartsBin.
>
> Best,
>
> - Marko

Marko:

Perfect, this is a great convention - just the sort of thing I was
looking for, as it makes it obvious there is a way for the Morph state
to be (re)initialized and is found by the method search!

I will be using that

Thanks,

milan


More information about the lively-kernel mailing list