Minimal Morphic?

Doug Way dway at mat.net
Sun Jan 16 23:49:37 UTC 2000


I haven't done much scripting in Morphic, but I've done a decent amount of
browsing/"regular" Morphic development, so hopefully this will help a
little, anyway...

On Sun, 16 Jan 2000, John Clonts wrote:

> Hello,
>
> I've been through as much docs as I can find on this, but I'm surely I'm
> making this much harder than it really is.
>
> In a morphic project, how is the way to hook one scrollbar to one
> stringmorph, where the stringmorph shows the value of the scrollbar?

It should be possible, given that it is already done in Play With Me 1.

> I've decided that it can't be done with the scripting panels-- is that
> correct?
>
> So I'm using browsers and inspectors and explorers, but I'm getting lost
> in the models, players, owners, costumes, etc :(
>
> Well here's what I did:
>
> * create a pasteupmorph
> * put into it a SimpleSlider ('slider1') and a StringMorph ('string1')
> * on the Slider menu I 'set action selector' to  #contents:, the
> arguments to value, and ---  What?  I thought there was a menu item to
> set the target ( to string 1), but its not there, so

I don't understand why this menu item is missing, either.  Sounds like a
bug.

> * open an inspector on the Slider and do ' self target: ( self world
> submorphNamed: 'string1').  Hmm, returns nil.
> * I inspect the Sliders model instance variable.  Oh, this looks good,
> the model has instance variables called slider1 and string1!  Great, so
> back at the Slider I do ' self target: ( self model string1)'.  Hmm,
> MorphicModel1 DoesNotUnderstand string1 !

You can cheat a bit here by using instVarNamed:, like this:  'self target:
(self model instVarNamed: 'string1')'.  (When I tried this, I noticed that
the model (MorphicModel1) already had an accessor for slider1, but none
for string1, oh well.)

One thing you will run into is that the SimpleSliderMorph seems to be
hardcoded to pass its "value" along in any addition to any user-set
arguments (see setValue:), so you won't need to use the "change arguments"
menu.

Also, another thing is that contents: in StringMorph will expect a String,
but the slider will pass a Float, so you will need to convert somewhere.
You could add a new method to StringMorph such as contentsFromNumber:
which does something like "self contents: newContents asString", then use
this as your action selector.  (It would have been easier to use "change
arguments" to do the conversion, though.)

> Please straighten me out!
>
> Also, sometimes on the morphs' menu I see 'Become the Model for the
> World'.  What does that mean?

I think this might have to do with why 'string1' and 'slider1' showed up
in your slider's model.  (Sometimes I couldn't get stuff to show up
there.)

Anyway, the power/promise of Morphic scripting is tangible, but it's still
a bit buggy at this point. :-)

- Doug Way
  dway at mat.net





More information about the Squeak-dev mailing list