Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
How are you implementing ITool.Deactivate? –  Kirk Kuykendall May 9 '12 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 –  Xoph May 9 '12 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 May 9 '12 at 19:08
    
Yes, that is what I meant –  Xoph May 9 '12 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 May 9 '12 at 20:44
show 2 more comments

1 Answer

up vote 1 down vote accepted

If IApplication.currenttool is your custom tool, return false for ITool.Deactivate, and set IApplication.CurrentTool = null in ICommand.OnClick.

share|improve this answer
    
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 May 9 '12 at 20:14
    
@Xoph I forgot you're in VB.NET. Did you try Nothing instead of Null? –  Kirk Kuykendall May 9 '12 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 May 9 '12 at 20:36
    
Does this just prevent other tools from being activated? –  blah238 May 9 '12 at 22:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.