OnUpdate and/or condition keyword in AddIns.xml not firing until button is clicked.

583
5
10-31-2013 07:35 AM
AlainProulx
New Contributor III
Hey folks,

I'm trying to disable an AddIn button on Startup but no events related to the button fire until button is clicked.

I tried overriding the OnUpdate event for the button and also tried using the condition="E3_ArcGISLayerSelectedCondition" in the AddIns.xml.  Both of these only fire once the button is clicked, which is too late.  I want it to fire on Startup.

Any Ideas?  Bug?

Thanks
Al
0 Kudos
5 Replies
NormanDeschamps
New Contributor III
setting the arbitrary condition for the button to show within the button addin should work. I have used the condition "folder selected" (can't remember the exact name), and the associated button is disabled on start up.  Is there another condition that is appropriate for what you are doing with the button?

A bit of a hack would be to use a second addin that is an extension. That extension addin can be easily set to run at Startup, and you can use that one to set the status of the button addin that you want disabled.

Norm
0 Kudos
AlainProulx
New Contributor III
Hey Norm, thanks for responding.

I tried multiple different conditions and I can never get it to fire.  I actually already have an extension and I can't get to the button to disable it.  The button isn't created until the button is clicked.  To prove this, override the "New" function in your button and put a debug statement in there.  For me, it doesn't get hit until the button is clicked.

' The following doesn't get hit until button is clicked.  Even with the Condition in the AddIns.xml.
Public Sub New()
   Me.Enabled = False
End Sub

FYI:  I'm running 2500.
0 Kudos
NormanDeschamps
New Contributor III
I am not sure what else to suggest, Al, except some basic things that you may have already tried. 

Try creating a brand new button with a condition such as
condition="E3_SingleFolderSelectedCondition"
Don't even add any code to it and save it as the default name that MS Visual gives the solution.

Does the new button start out greyed out when you start up AGX with the default map?

Try deleting the current default map, then manually add in the test button yourself to the new default map that AGX automatically creates the next time you start the program.

As I said, the condition in AddIns.xml works on my system, so I can only assume it should work on yours if we can get things basic enough.
What version of Windows and Visual Studio are you running?
Norm
0 Kudos
AlainProulx
New Contributor III
Thanks again for piping up.

I just tried installing on a windows 7 64 bit/32 bit and Windows 8 no go.  Tried creating a barebones, all defaults Explorer addin with one button and still no go.  I have to click on the button before any disabling/enabling occurs.

This one has me stumped.

can you confirm that you are using Version 2500?  I haven't tested on the earlier versions.
0 Kudos
NormanDeschamps
New Contributor III
Yeah, I'm using 2500 as well.
I wish I had more to offer, but at the moment I have nothing. I'll think about it some more, and if I come up with anything, I'll post.

Norm
0 Kudos