I am using VB.Net to write an add-in. I'd like to keep the tool that I created selected even when the user attempts to select a different tool, and only deselect when my tool is clicked on again.
-
How are you implementing ITool.Deactivate?– Kirk KuykendallCommented May 9, 2012 at 18:28
-
I haven't implemented it yet. I figured this would be the key to doing this, but I wasn't sure what to put inside the Deactivate method– XophCommented May 9, 2012 at 18:30
-
When you say: "keep the tool that I created selected even when another tool is selected" do you really mean: "keep the tool that I created selected even when the user attempts to select a different tool"?– Kirk KuykendallCommented May 9, 2012 at 19:08
-
Yes, that is what I meant– XophCommented May 9, 2012 at 19:10
-
Sorry, your interpretation was not exactly correct, what I mean is that I would like to keep my tool active, even when the user selects another tool. When the user clicks on the tool again, it should the deactivate my tool.– XophCommented May 9, 2012 at 20:44
|
Show 2 more comments
1 Answer
If IApplication.currenttool
is your custom tool, return false for ITool.Deactivate
, and set IApplication.CurrentTool = null
in ICommand.OnClick
.
-
Setting it to null tells me to convert to DBNull.Value, but this gives me the warning "Runtime errors might occur when converting 'System.DBNull' to 'ESRI.ArcGIS.Framework.ICommandItem'"– XophCommented May 9, 2012 at 20:14
-
@Xoph I forgot you're in VB.NET. Did you try
Nothing
instead ofNull
? Commented May 9, 2012 at 20:26 -
Nothing works. I'm still hazy on where to set IApplication.CurrentTool = nothing? You say in ICommand.OnClick. Should this be a ReadOnly Property or how do I implement it?– XophCommented May 9, 2012 at 20:36
-