Custom Actions

[Top]  [Chapter]  [Previous]  [Next]

Since Version 1.3 of TextDynamic it is also possible to create custom action names in the PCC file.

 

add_custom_action

The name of the Actions XML script must be "default" - only one is allowed in a PCC file.

 

Such Custom actions can be used to enable/disable buttons and menu entries in the GUI.

 

The action names can be used similar to predefined wpa actions in the toolbar description only that the name is specified in the "Action" instead of the "wpa" parameter.

 

Custom actions will get a dynamic action id which can be retrieved using method wpaGetID and used with wpaSetFlags / wpaGetFlags Parameters:

 

name:        the name of the action

c:        the default caption

h:        the default hint

alias:        optional alias string to be used by the application

param:        optional string parameter

 

Custom action names can be used in the Action="" parameter for  button and menu entries in the EditLayout.

 

Example:

 

<wpa>

<action name="custom_example" c="Do something" h="This is just a test for custom actions."/>

</wpa>

 

In the application wapSetFlags can be used to change the state of the custom action, ie. disable it:

 

private void WPDLLInt1_OnUpdateGUI(object Sender, int Editor, 

        int UpdateFlags, int StateFlags, 

        int PageNr, int PageCount, int LineNr)

{

   byte[] flags = WPDLLInt1.wpaGetFlags(Editor);

   int i = WPDLLInt1.wpaGetID("custom_example");

   if (i>=0)         

      {

         flags[i] = (byte)(flags[i] & 0xE); // delete bit 1 = disable!

         WPDLLInt1.wpaSetFlags(Editor, 0, flags.Length, flags);

      }

}

 


[custom_actions.htm]    Copyright © 2007 by WPCubed GmbH