Documentation Center

Enabling or disabling a control

You can enable or disable a UI control object based on a predefined condition by editing attributes of its corresponding control element in the controls.xml file.

About this task

When a control is enabled, it is clickable and its appearance is controlled by an attribute in the controls.xml file. You can use this functionality to customize the availability of a control based on conditions you specify. For example, you may want to enable the Next Image icon control when the image being viewed is not the last in a series, but disable it when the last image is being displayed. To do so, add the applicable conditions to <enabled> and <disabled> tags within the Next Image control's definition in the controls.xml file.

Procedure

  1. Open the controls.xml file in a text editor.
  2. In the controls.xml file, locate the control element corresponding to the desired UI object.
    For example, to show or hide the Next Image icon, locate the <control id="CVCtrl_nextImage" type="icon"> tag.
  3. To specify a condition under which the control is to be enabled, between the element's opening and closing tags, add or edit the <enabled> attribute to include a predefined condition name and status such as the following.
    <enabled className="toolbar_button gbar_next toolbar_left">
    				<condition name="multipleGraphics" status="true"/>
    </enabled>
    In this example, the icon will be enabled if the condition multipleGraphics evaluates to true, indicating that the currently open module contains more than one graphic. The opening <enabled> tag also specifies a class to be applied to the icon to determine its appearance when it is enabled.
  4. To specify a condition under which the control is to be disabled, between the element's opening and closing tags, add or edit the <disabled> attribute to include a predefined condition name and status such as the following.
    <disabled className="toolbar_button_disabled gbar_next_off toolbar_left" default="1">
    				<condition name="multipleGraphics" status="false"/>
    			</disabled>
    In this example, the icon will be enabled if the condition multipleGraphics evaluates to false, indicating that the currently open module does not contain more than one graphic. The opening <disabled> tag also specifies a class to be applied to the icon to determine its appearance when it is disabled.
  5. Save and close the controls.xml file.