1

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 9, 2012 at 18:20
7
  • How are you implementing ITool.Deactivate? Commented 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 Commented 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"? Commented May 9, 2012 at 19:08
  • Yes, that is what I meant Commented 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. Commented May 9, 2012 at 20:44

1 Answer 1

2

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
4
  • 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'" Commented May 9, 2012 at 20:14
  • @Xoph I forgot you're in VB.NET. Did you try Nothing instead of Null? 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? Commented May 9, 2012 at 20:36
  • Does this just prevent other tools from being activated? Commented May 9, 2012 at 22:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.