I want the user to click on a toolbar button and then when the mouse is clicked on the goview object, I want to paste/add the node (CollapsingRecordNode) to the document.
Im tring to use the GoToolCreating for the same.
The problem is that the node does not retain the width and the header/node text is a little misaligned.
How do I fix the width and the text alignment (By default the width of this node is set to 130)?
I havent tried that
Will try it out and let you know.
It worked when I did not use GoCreatingTool.
Meaning, On a toolbar button click added a node to the top left corner of GoView.
If it helps Im using the same code to create the node in both cases.
Well, it’s possible the properties you’ve added require you to override CopyObject… or more likely CopyChildren.
Try your CreateTool with the stock CollapsingRecordNode… it that works (it should) and your node doesn’t, that’s probably the problem. Look at how other sample classes implement CopyChildren.
I modified the DrawDemo project to only paste CollapsingRecordNode when using CreateTool and still see the same issue.
Code from MainForm.cs (DrawDemo) that was edited:
private static GoObject GetDropObjectFromPaletteObject(GoObject proto) {
//GoIconicNode ic = proto as GoIconicNode;
//if (ic != null) {
// GoShape shape = ic.Icon.Copy() as GoShape;
// shape.Size = new SizeF(shape.Size.Width * 3, shape.Size.Height * 3);
// shape.Selectable = true;
// shape.Shadowed = false;
// shape.Resizable = true;
// shape.Reshapable = true;
// shape.ResizesRealtime = true;
// proto = shape;
//}
proto = new CollapsingRecordNode();
return proto;
}
Still didn’t work for me, so I created a new Creating tool inheriting from GoCreatTool.
In DoMouseUp() I set the itemwidth after Document.AddCopy and this worked for me.
I really don’t know why it gets sized that way before the drop.
However, GoToolCreating is for a mouse-down-drag-to-size-mouse-up operation.
I think the rubber stamp (ClickCreateTool in DrawDemo) is probably a better choice as a starting point (although you may want to add the “one shot” feature).