[squeak-dev] Re: isKindOf: in Morphic code...

tim Rowledge tim at rowledge.org
Tue Jul 5 16:46:30 UTC 2016


> On 05-07-2016, at 6:17 AM, karl ramberg <karlramberg at gmail.com> wrote:
> 
> A lot of the isKindOf: sends is used to find specific submorphs.
> 
> ButtonMorph>>label
> 	| s |
> 	s := ''.
> 	self allMorphsDo: [:m | (m isKindOf: StringMorph) ifTrue: [s := m contents]].
> 	^ s
> 
> One could give names to the submorphs as they are initialized, all morphs understand 'name:'
> 
> Would that be a solution ?

That’s close to what I was suggesting except that I don’t much like the idea of giving a morph a name; it would be more effective to have an instvar in the *owner* and properly track the owned morph that way. For  example in a ButtonMorph I suggest we should have an instvar ‘label’ and when we set the label morph it should be put in that instvar as well as in the submorphs list. That way we can find it quickly, correctly, without the isKindOf: or even isTextMorph. And after all, both of those prevent a graphic label.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Useful Latin Phrases:- Oblitus sum perpolire clepsydras! = I forgot to polish the clocks!




More information about the Squeak-dev mailing list