GoView.ReplaceMouseTool

Hi,

I'm using ReplaceMouseTool(typeof(GoToolLinkingNew),myNewLinkingTool) and it works great... But just for the first time. From the second time and on when i replace the mouse tool it still uses the first one even if i set it to null!!!.
Any suggestions?
Thanks,
Adi

ReplaceMouseTool uses only the type you pass it.

so if you do:
ReplaceMouseTool(typeof(GoToolLinkingNew), new GraphViewLinkingNewTool(this));
you have to do:
ReplaceMouseTool(typeof(GraphViewLinkingNewTool), null);
to remove it.
or... FindMouseTool actually gives you the option to search for a subclass of the type
ReplaceMouseTool(typeof(GoToolLinkingNew), new GraphViewLinkingNewTool(this));
IGoTool t = FindMouseTool(typeof(GoToolLinkingNew), true);
ReplaceMouseTool(t.GetType(), null);

So, In my case, when i try to replace the linking tool with the same type (myLinkingTool) but another instance it has no effect because you see that the type is the same and ignore it… Am i correct? if so, then i must find other ways to replace the tool behavior.
Thanks,
Adi

No, GoView.ReplaceMouseTool, when looking for a Type of tool, just does an exact comparison instead of looking for a subtype class relationship.

So you can do it either way that Jake suggested.