Le Sunday 27 August 2006 18:02, Keith McKay a écrit :
> 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.
I see two solutions :

one is to make two new classes :
PluggableTextMorphWithMargins that is a subclass of PluggableTextMorph
TextMorphForEditViewWithMargins that is a subclass of TextMorphForEditView

and one method in each new subclass :
PluggableTextMorphWithMargins>>textMorphClass
        "Answer the class used to create the receiver's textMorph"
        ^ TextMorphForEditViewWithMargins

TextMorphForEditViewWithMargins>>initialize
        super initialize.
        self margins: [EMAIL PROTECTED]

And now you can use PluggableTextMorphWithMargins instead of PluggableTextMorph.

another solution is two send 'ptm textMorph margins: [EMAIL PROTECTED]' to your 
PluggableTextMorph instance (ptm) from
PluggableTextMorph instance owner (in your GUI class initialize instance method 
for example). 
I think this is a better way ('one particular need, one subclass' is often not 
a good scheme...)

alain
> 
> Thanks
> 
> Keith
> Hamilton, Scotland
> 
_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to