[Newbies] Beginners Digest, Vol 123, Issue 4
ratcheer at gmail.com
Wed Feb 22 22:50:53 UTC 2017
> One of the articles on Morphic says you can create composite morphs
> using addMorph, or using drag and drop from the Objects menu of the
morphic World. I have
> done the latter, because it is easier to design my layout that way. Once
that has been done,
> how do I address the submorph from a browser? If I inspect my button
submorph, for example
>, all it will tell me about it is "a ScriptableButton<Button>(1364754)". I
have no idea how to
> access that object in order to do anything with it. This is the crux of
This is, in my opinion, the most significant limitation of Morphic for
interactive GUI creation. In the original Morphic in Self the way to
handle this was to simply search through all your submorphs for the one
you were interested in, usually by comparing the morphType string. In
Squeak we can add properties to Morphs very easily so that would be one
way to tag it. Something like:
| stopButton |
stopButton := nil.
self submorphsDo: [ :m | (m hasProperty: #stopButton) ifTrue: [
stopButton := m ] ].
stopButton ifNotNilDo: [ :b | b ... ].
Code like this will work even if there are no stopButtons at all and if
you add more than one the code will just use the last one and ignore the
After creating the button you have to get its halo and use the red
button (menu) with the debug->inspect morph option to set the
An alternative to using specially created properties is to depend on the
morph's name. In your case it is "a ScriptableButton<Button>(1364754)"..
self subMorphsDo: [ :m | (m name includesSubString: 'Button') ifTrue:
should work for you as long as there is only one button.
Thank you, Jecel, for trying to help me solve my problem. However, my plan
is to have multiple sibling morphs for both the buttons and the texts.
So, I am diving in to trying to use addMorph: programatically to add
submorphs to my display. This allows me to hold a reference to each
submorph in named variables, through which I should then be able to specify
state changes and act on events to and from my submorphs.
Maybe my mindset is just too old fashioned. Back in the 90's, I programmed
MVC applications in VisualWorks. I thought Morphic was supposed to be much
easier to use than MVC, but so far, I have not been able to figure out how
to control my objects in Morphic.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners