Accessing Morphs as objects

Ned Konz ned at bike-nomad.com
Tue Jun 4 22:35:51 UTC 2002


On Tuesday 04 June 2002 03:01 pm, Geza Lakner MD wrote:

> > that's named something like "create text references to dropped
> > morphs". If you select this and drop (almost) any Morph on the
> > Workspace, you'll get a new binding for that Morph. You can then
> > use
>
> Sorry but I can't get it:
> I open the Supplies flap, choose a Playfield - then I can drag OVER
> the Workspace window, but not ONTO it.
> Nothing happens, even if I open the TRanscript window. Occurs the
> bindig silent - how can I check what name has been referenced to
> the morph?

You have to choose the menu item in the Workspace first:
click on the menu button (upper left corner next to the X), check 
"create text references to dropped morphs".

Now drop a Morph on the Workspace. Three things happen:
* The morph slides back to where it was
* a binding gets created between a generated name and the Morph
* the name gets pasted into the Workspace as text.

> > You can't find those objects, since the Browser just displays a
> > class-centric view.
>
> But aren't they instances?

Sure, but the Browser deals with classes. The only reference to these 
instances is the connection between the World (a PasteUpMorph) and 
its submorphs.

You could get to the Morph that way:

* Name the Morph (bring up the halos and edit the name)

* Then go:
	World submorphNamed: 'TheName'
where 'TheName' is the Morph's name.

> I would not force this external reference thing. Just to ask: If
> you want to have a dialog box with some GUI controls (buttons, text
> fields) in it - how would you set up the system?

I usually build it first using direct manipulation (to see what it 
looks like) and then open the Object Explorer on it. I then look at 
the various instance variables that hold the results of my changes 
and write those changes into an initialization method. Then I test.

There have been a couple GUI builder apps written, though I don't know 
the state of them (whether they work in the current 3.2g version or 
not). Look at:

http://minnow.cc.gatech.edu/squeak/1576

> If there is no clear programmatic connection the GUI editor and its
> obejct references, how do you access e.g. the contents of a text
> field in your program? Or do you use only this toy-grade scripting?
> Or do you drop GUI editing entirely and return the class-based
> classical method to create a dialog box textually, by hand?

*I* usually just do it by hand.

> Sorry if these questions represent a totally confused mind, but on
> a usual GUI system (e.g. Delphi) you drop an element onto the
> canvas, name it and then you can use its name purely to access its
> methods, flags, contents etc. What is the most elegant, Squeak-ish
> approach to have e.g. GUI database forms?

Get someone's GUI builder package and use it. The world of databases 
and text entry fields is really not what Squeak Central seems to be 
focused on, though there are certainly Squeak users who want such 
things.

I've long thought that a viable approach would be to make an app that 
just reads dropped Morphs and writes the appropriate methods in a 
class definition.

Or one that would read an XML spec produced by Glade and build a UI. 
Though this isn't all-Squeak, it does leverage a good bit of code 
that's already done. However, the widgets themselves would have to be 
written to match the Gtk ones.

> > could just use #dup to get one. I do this in my Connectors
> > package with the NCMakerButtons: they hold onto copies of Morphs
> > that are
>
> Where can I find this instructive package to get a glance on the
> source code what happens behind the curtains?

http://bike-nomad.com/squeak/

> Now I think I came closer: IF they are instances, what is their
> name (reference)? Or are they only "void", referenceless instances?

As I said, they are only referenced as submorphs of their parent 
(usually the World), unless you choose to reference them some other 
way. However, the World is a global, and you could work from there 
(perhaps by using names, or selection blocks).

> I meant a script window which holds the raw textual (editable)
> representation of a morph method.

No, that doesn't happen. However, you can take a tile script and view 
it as Smalltalk text, which can then be copied. Note, though, that 
the operational environment of a scripted Morph is probably different 
than you'd expect: scripted actions don't end up in the Morph class, 
but in a Player subclass with a unique name. The Morph then points to 
a Player instance, and will refer to it for scripting-related 
behavior.

> > There is no interaction that I know of between the regular
> > Smalltalk browsers and other tools and the tile scripting system.
>
> Once again ... two different worlds with no apparent connection
> betweem them :-((( which would make them a complete GUI-IDE system.

What you see in the tile scripting system wasn't intended to be a 
"complete GUI-IDE system" in the common sense (that is, for making 
business applications, etc.).

It was intended as an educational tool that would let kids build 
simulations (I think; it's best to refer to the "official" sources 
for this, as I'm not focused on the educational uses of Squeak).

See, for instance, http://www.squeakland.org

This isn't to say that Morphic wouldn't make an excellent platform to 
write a more conventional GUI atop (it would, and has). Just that 
this isn't provided for "out of the box".

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list