Double click on a GoMultiTextNode


#1

Hi,
I have a class that inherits GoMultiTextNode. In the nodes I create I add items to the node’s underlying ListGroup by calling AddString several times.
Each GoText in the ListGroup is selectable. When the user selects an item in the node, the item changes color automatically to show the selection is on the node’s GoText sub-item. I realize there must be someway to get the GoText selected, but I can’t find out how. I need to be able to react to a double-click in the node and know which GoText in the ListGroup was double-clicked.
The way I’m trying is to handle the ObjectDoubleClicked event and using the sender’s Primary Selection. That however amount to the whole node, not the double-clicked GoView. I can’t find any helpful events on the GoText either.
Can someone help me?
Thanks !


#2

The result of GoMultiTextNode.AddString is a GoText object that is not Selectable. So the first thing you need to do is set it to be Selectable. By default it also sets BackgroundOpaqueWhenSelected to true and BackgroundColor to be light blue.
When the user clicks on one of these text objects, it becomes selected, which means the GoView.Selection will include that GoText object. If you are examining the selection, you will need to look at the type of the object to see if it is a GoText, and you will need to look at the parent object to see which GoMultiTextNode it’s part of.
You can either install a GoView.ObjectDoubleClicked event handler or you can override GoText.OnDoubleClick. If you do the latter, you’ll probably want to override GoMultiTextNode.CreateText to create an instance of your text class instead of the standard GoText class. Here’s what GoMultiTextNode.CreateText normally does:
public virtual GoText CreateText(String s, int idx) {
GoText t = new GoText();
t.Selectable = false;
t.Alignment = GoObject.Middle;
t.Multiline = true;
t.BackgroundOpaqueWhenSelected = true;
t.BackgroundColor = Color.LightBlue;
t.DragsNode = true;
t.Text = s;
t.Wrapping = true;
if (this.ItemWidth > 0) {
t.WrappingWidth = this.ItemWidth;
t.Width = this.ItemWidth;
}
return t;
}


#3

Thanks for your help Walter