Update DisabledText

04-28-2016 05:58 AM
Occasional Contributor III

I have tools with conditions that have  several states that determine if the tool is enabled or disabled.  If the tool is disabled, I would like to be able to use the DisabledText property to inform the user which state(s) are causing the tool to be disabled so they know what to do to enable it.  But I can't find an event that occurs when the MapTool becomes disabled.  Is this possible?

0 Kudos
1 Reply
Esri Regular Contributor

Hi Ted,

Here is a way to customize the disabedText property of a button\tool:

* Set the tool's loadOnClick attribute to "false" in the config.daml. This will allow the tool to be created when Pro launches. This way the disabledText property can display customized text at startup.

* Remove the "condition" attribute from the tool. You will be using the OnUpdate method to set the enable\disable state of the tool.

* Add the OnUpdate method to the tool. The code for it will be something like this:

protected override void OnUpdate()
            bool enableSate = true; //TODO: Code your enabled state
            bool criteria1 = true//TODO: Evaluate criteria for disabledText
            bool criteria2 = false; //TODO: Evaluate criteria
            bool criteria3 = true; //TODO: Evaluate criteria

            if (enableSate)
                this.Enabled = true;  //tool is enabled
                this.Enabled = false;  //tool is disabled
               //customize your disabledText here
                if (criteria1)
                    this.DisabledTooltip = "Missing criteria 1";
                else if (criteria2)
                    this.DisabledTooltip = "Missing criteria 2";
                else if (criteria3)
                    this.DisabledTooltip = "Missing criteria 3";

Note: since OnUpdate is called very frequently, you should avoid lengthy operations in this method as this would reduce the responsiveness of the application user interface.


Uma Harano

ArcGIS Desktop SDK Team

0 Kudos