[Q] perform: selector

David Faught dave_faught at yahoo.com
Fri Dec 20 17:46:37 UTC 2002


On Friday 20 December 2002 09:15 am, Ned Konz wrote:
>On Friday 20 December 2002 08:47 am, David Faught wrote:
>> There is already an 'addLabel: string' method that works fine, and
>> I am defining the method:
>>
>>   beLabeled: aSelector
>>         self addLabel: (self perform: aSelector asString).
>>
>> and trying to use it as in:
>>
>>   aMorph beLabeled: #externalName
>>
>> where I am expecting aMorph to end up with a label containing the
>> text returned by the aMorph externalName method.  DOing this line
>> results in a "message not understood" error.  What is the right way
>> to do this?
>
>David, are you using Connectors still? There isn't a general purpose
>Morph #addLabel: method.
>
>#addLabel: on NCConnectorMorph takes an event, not a string.
>
>If you just want to add a label with an arbitrary string, you could
>use #addLabel:at: or #addLabel:near: and pass the connector's
>midpoint (or end, or whatever) as the point.
>

Yes, I know.  I have overridden the NCConnectorMorph's #addLabel:
method in my own subclass and added the #addLabel: method to my other
morphic subclasses.  As I said above, if I do:

  aMorph addLabel: 'a string'

it works just fine.  What I am trying to do is make one method that
will allow me to add labels with various contents that aMorph already
knows about, like externalName and instance variables that have methods
returning their values.

I am working toward being able to say things like:

  NetCircuit allBeLabeled: #externalName
  NetCircuit allBeLabeled: #bandwidth
  NetCircuit allBeLabeled: #pingTime

and choose between these things dynamically without having to write a
separate labeling method for each type of label contents.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the Squeak-dev mailing list