Hi

I have found a solution to my problem.

If you send the message allMorphs to a morph it returns a collection
containing all morphs in the composite morph including the receiver.

In this case a PluggableTextMorph would give:

aPluggableTextMorph allMorphs>> an OrderedCollection(a RectangleMorph(1207)
a RectangleMorph(3700) a RectangleMorph(1462) an ImageMorph(2630) a
RectangleMorph(2661) an ImageMorph(3061) a RectangleMorph(299) an
ImageMorph(464) a RectangleMorph(1782) a ScrollBar(1419) a
TextMorphForEditView(2717) a TransformMorph(726) a PluggableTextMorph(127))

I had used submorphs at first but this confused me because it returned #(a
ScrollBar(1109) a TransformMorph(2472)).  But then I found allMorphs which
worked.

I had thought that the PluggableTextMorph contained a TextMorph as a
submorph since it had an instance variable of that name but it turns out
that it is a TextMorphForEditView which I found after browsing the
PluggableTextMorph class.  So knowing that TextMorphForEditView inherits
from TextMorph I knew I could play about with the margins and other layout
properties of TextMorphs. But how to get to the TextMorphForEditView?  The
instance method in Morph held a clue

allMorphs
        "Return a collection containing all morphs in this composite morph
(including the receiver)."

        | all |
        all _ OrderedCollection new: 100.
        self allMorphsDo: [: m | all add: m].
        ^ all

The message allMorphsDo: aBlock was the answer!

My solution is..

| aPluggableTextMorph |

aPluggableTextMorph allMorphsDo:[:each | (each isKindOf:
TextMorphForEditView)
                                                ifTrue:[ each margins:
[EMAIL PROTECTED]

This works well but is it the best way to access submorphs?

Thanks
Keith

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Keith
McKay
Sent: 27 August 2006 17:03
To: [email protected]
Subject: [Newbies] PluggableTextMorph


Hi

I'm looking for some advice on setting the margins in a
PluggableTextMorph(PTM) programaticaly. It can be done easily once the PTM
is open in the World by drilling down to the TextMorph and invoking its menu
using the halos, but I would like the option of initialising them, or adding
as an item to a menu of the PTM.

Am I missing something obvious? Should I just use a TextMorph instead? Hints
rather than solutions would be preferable.

Thanks

Keith
Hamilton, Scotland

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/428 - Release Date: 25/08/2006
 

_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/428 - Release Date: 25/08/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/428 - Release Date: 25/08/2006
 

_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to