Change selection/editing style of GoText

My nodes and links both have a label. I derived the label class from GoText and want a special selection behaviour. On a first click it should become selected and on a second click (or F2) change to edit mode. Similar to behaviour of Windows Explorer file entries.

GoText switches to edit mode already on first click an user has to press ESC to move label. I did not find such option and tried to override OnSingleClick. But i couldnt get it working because i dont see a way to detect if label is clicked first or second time. Walter, can you please tell me, how to do this. Thanks in advance :-)

Did you want the GoText object to be selected? I.e., did you want that object (rather than a node or a link) to be part of the GoView.Selection?
If so, then perhaps you could just use its being selected in the view that got the click as the indication that you should go into edit mode.
If not, then there needs to be some other way to keep track of what the user just clicked on. I would implement a GoView.ObjectSingleClicked event handler and remember for that view what the user last clicked on. Then if it’s a second click and it’s a GoText and if GoText.CanEdit() is true, call DoBeginEdit.

Walter, i am not sure if i understand you correctly. My labels are selectable on their own. The node/link which belongs to a label does not need to be selected.

My first attempt was to check in OnSingleClick of my label class if view.selection contains my label. But its true even for the first click. Apparently it gets selected before OnSingleClick is executed.

So i have to implement a view.ObjectSingleClicked as you suggested. Is it right?

Ok, there is another thing i need help with.

I have done it, like i understood your post. My view class now has a property ‘LastClickedNetElement’ and in MyLabelClass.OnSingleClick i set this property. Unfortunately it is not generic. Every class i want to have this ClickOnSelection information for, has to implement OnSingleClick to set ‘myView.LastClickedNetElement = this’. I guess there is no way to generalize it in an resonable amount of time :-(

Now the question: In some event args i get the GoObject for which the event occured (view.ObjectSingleClicked, view.ObjectContextClicked…). If i click on a node this event occurs for the shape contained in the node (e.g. a GoRectangle). How can i get the object i added to the view for any subelement i get by event args?

You shouldn’t need to override any GoObject methods to do what you want, since you can just implement a single GoView.ObjectSingleClicked event handler that looks at the value of e.GoObject.
Yes, it’s true that the e.GoObject value will be whatever object is “in front” at the given point, so if you want to find the node you’ll need to look at the e.GoObject.ParentNode or whatever.