Text and Label


I am just starting with GoDiagram so this may be a bit basic …
I started using a GoSimpleNode and then changed to GoIconNode. In the GoSimpleNode I could explicately set the Text and the Label. In GoInconNode these two attributes are somehow ‘bound’ together and if you change one, the other changes.
How can I stop this from happening?


To answer your immediate question: the GoIconicNode.Text property is implemented as (delegated to) the GoIconicNode.Label.Text property. You’ll need to add a String field to your GoIconicNode subclass, and then override the Text property to get and set that new field:
public override String Text {
get { return myText; }
set {
String old = myText;
if (old != value) {
myText = value;
Changed(ChangedText, 0, old, NullRect, 0, value, NullRect);
public const int ChangedText = LastChangedHint+1;
private String myText = “”;

But I don’t see how you can set the Text and Label.Text independently of each other. It is true that you could create a GoSimpleNode without a Label, and yet have it continue to have a settable Text property, but otherwise the GoSimpleNode.Text and GoSimpleNode.Label.Text values normally always have the same values.
[The doc string seems to imply otherwise, although it doesn’t say how to cause Label.Text changes, say due to user editing, not to be reflected in the GoSimpleNode.Text value. The answer is to call x.Label.RemoveObserver(x). But setting GoSimpleNode.Text still modifies the Label’s Text value. We should make it easier to decouple the two Text properties.]


Your code ‘fixed’ my problem. I want the text to have a unique id for each node so I can find them on the diagram when needed using findnode. The label may not be unique for all nodes.
I have a new problem relating to autolayout so I will start a new thread.
Ian McVay