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 Kuykendall– Kirk Kuykendall2012年05月09日 18:28:38 +00:00Commented 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 methodXoph– Xoph2012年05月09日 18:30:20 +00:00Commented 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 Kuykendall– Kirk Kuykendall2012年05月09日 19:08:45 +00:00Commented May 9, 2012 at 19:08
-
Yes, that is what I meantXoph– Xoph2012年05月09日 19:10:58 +00:00Commented 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.Xoph– Xoph2012年05月09日 20:44:48 +00:00Commented May 9, 2012 at 20:44
1 Answer 1
If IApplication.currenttool
is your custom tool, return false for ITool.Deactivate
, and set IApplication.CurrentTool = null
in ICommand.OnClick
.
answered May 9, 2012 at 19:29
-
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'"Xoph– Xoph2012年05月09日 20:14:41 +00:00Commented May 9, 2012 at 20:14
-
@Xoph I forgot you're in VB.NET. Did you try
Nothing
instead ofNull
?Kirk Kuykendall– Kirk Kuykendall2012年05月09日 20:26:46 +00:00Commented 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?Xoph– Xoph2012年05月09日 20:36:24 +00:00Commented May 9, 2012 at 20:36
-
Does this just prevent other tools from being activated?blah238– blah2382012年05月09日 22:09:15 +00:00Commented May 9, 2012 at 22:09
default