rise and sink of Custom Tool when Click

2460
9
Jump to solution
08-11-2011 07:45 PM
by Anonymous User
Not applicable
Original User: pumskins

I Created a Custom Tool for arcmap 9.3.1 in .net. When the tool is click it will sink, is there a way to programmatically to rise it again when the user click other controls like button?

You can see the attached image for reference.

Any help is appreciated.


Thanks,

Francis
0 Kudos
1 Solution

Accepted Solutions
BerendVeldkamp
Occasional Contributor II
That should happen automatically when a user selects a different tool (e.g. zoom in). You can also do this programmatically by setting the IApplication's CurrentTool property to another tool.

View solution in original post

0 Kudos
9 Replies
BerendVeldkamp
Occasional Contributor II
That should happen automatically when a user selects a different tool (e.g. zoom in). You can also do this programmatically by setting the IApplication's CurrentTool property to another tool.

View solution in original post

0 Kudos
by Anonymous User
Not applicable
Original User: dubravko.antonic

Checked state is controlled by ICommand.Checked member that you can override.
As bveldkamp wrote it should happened automatically when you set another active tool, but sometimes ArcMap doesn't do it right way. This could be sign of some hung method or some error in extension.
I got that problem but usually doesn't last long until ArcMap refreshes UI.
0 Kudos
NeilClemmons
Regular Contributor III
You have to implement the ITool.Deactivate method so that it returns True.  If you don't, then your tool cannot be de-selected.
0 Kudos
by Anonymous User
Not applicable
Original User: pumskins

Thanks guys for the quick response, It will automatically deactivate when other tool is selected but i want to trigger the deactivate function of the tool when I click a button.

I will going to try this out and I will let you know as soon as I figure it out. Thanks guys,your help is highly appreciated.


Regards,

Francis
0 Kudos
DubravkoAntonic
New Contributor III
Your requirement is still unclear what tool you want to trigger on Decativate event?

If you want to do something when your tool is not active tool use Neils tip.
If you want to do something when some other tool, that you don't implement in your extension you can just test if the tool is active and after that if is inactive. In ArcMap in ITool Enabled is invoked at least once a second.

Other way goes very low into hooks, but this can be uneficient way of solving your issue.
0 Kudos
by Anonymous User
Not applicable
Original User: pumskins

Your requirement is still unclear what tool you want to trigger on Decativate event?

If you want to do something when your tool is not active tool use Neils tip.
If you want to do something when some other tool, that you don't implement in your extension you can just test if the tool is active and after that if is inactive. In ArcMap in ITool Enabled is invoked at least once a second.

Other way goes very low into hooks, but this can be uneficient way of solving your issue.



I apologize sir for not making my self clear.

I have this tool(base tool) and a button(base command) in a toolbar. When I click the tool it will activate(sink appearance) and run codes within that tool. What I'm trying to figure out is when I click my button on the same toolbar I want that Tool whose previously active(sink) to be deactivated(rise appearance).


I added this function on my tool whose name is tool1

    Public Function ITool_Deactivate() As Boolean
          MyBase.Deactivate()
    End Function


and call it in my base command

        Dim Identification As New Identification.Tool1
        Identification.ITool_Deactivate()

During debugging, function ITool_Deactivate is called but no success, tool is still in active(sink) state. I dont know if it needs refreshing or I did something wrong.

Any help is appreciated. code snippet is welcome, im using vb.net 2008 and SDK 9.3.1.

regards,

Francis
0 Kudos
DubravkoAntonic
New Contributor III
If you want to deactivate tool you should tell ArcMap to deactivate your tool.
By default ITool.Deactivate returns true, but if you want to control deactivation of your tool implement this as Neil wrote.

To deactivate your tool you should set another active tool in IApplication. When that tool becomes active your tool should raise. After that you can set in IApplication.ActiveTool = null; and there will be no active tool.
If you just set active tool to null your button will remain sunk but tool will be inactive.

Deactivate is not meant to be called to deactivate it is just attribute that tells ArcMap if your tool can be deactivated. If you return false, your tool remains active and ir you return true your tool will no longer be ActiveTool in IApplication.

I hope this is what you need.

PS please don't apologize, I want to help, and we are all here to learn from each other.
0 Kudos
by Anonymous User
Not applicable
Original User: pumskins

Thanks very much dubravko.antonic, I'll try it and let you know if I figure it out.
0 Kudos
by Anonymous User
Not applicable
Original User: pumskins

Thanks guys to all your help. I figure it out already.

I just set the current tool to nothing when the click event in my button is triggered.
0 Kudos