Altova Authentic 2024 Browser Edition

AuthenticToolbarButtons.NewCustomButton

Accueil Préc Haut Suivant

Declaration: NewCustomButton(nPosition as long, strName as String, strTooltip as String, strBitmapURL as String)

 

Description

Inserts a new custom button with the name strName at the position nPosition of the toolbar. nPosition starts at 1.

strTooltip is taken as the Tooltip text.

 

strBitmapURL is the location of the bitmap to display for the new button. This path is relative to the path set with the TextStateBmpURL property.

 

Example

 

Imagine you have inserted a custom button with the name "MyFunction" to your toolbars. The following event handler for doceditcommand shows you how to react if the user clicked your button and how to set the enabled / disabled state for it.

 

 

<SCRIPT LANGUAGE=javascript FOR=objPlugIn EVENT=doceditcommand>

 // event.type is set to "command" if the user clicked the button

 if(objPlugIn.event.type == "command")

 {

         if(objPlugIn.event.srcElement.Name == "MyFunction")

                 window.alert("You pressed my custom button!");

 }

 

 // event.type is set to "update" if the button state must be set

 if(objPlugIn.event.type == "update")

 {

         if(objPlugIn.event.srcElement.Name == "MyFunction")

         {

                 // we enable the button if only one element is selected

                 if(objPlugIn.CurrentSelection.Start.IsSameNode(objPlugIn.CurrentSelection.End))

                         objPlugIn.event.returnValue = 1;

                 else

                         objPlugIn.event.returnValue = 0;

 

                 objPlugIn.event.cancelBubble = true;

         }

 }

</SCRIPT>

 

© 2017-2023 Altova GmbH