Tabax Plugin API
From Axaptapedia
Plugin API is supported by Tabax from version 0.3
Contents |
[edit] goals
Provide users of tabax some methods to modify it without changing it's source code.
[edit] what is plugin
Plugin is a class with name starting with the 'TabaxPlugin_' prefix and which has a 'tabax' property
Tabax enumerates such classes and sets the 'tabax' property to itself (see 'attachPlugins' method of the 'Tabax' form)
[edit] what plugin can do
When Tabax sets the 'tabax' property of plugin it can modify it behaviour by:
- subscribing to events
- using methods of tabax
For ease of use available events and utility methods are in the TabaxPluginBase class. Tabax service methods are in the Tabax abstract class.
[edit] example
Tabax plugin SDK contains an example of plugin, which modifys default behaviour of Tabax input box the following way: if you input a string like "hello <some word>" it outputs to the infolog Hello, <some word>
Source code:
/// Hello world plugin for tabax class TabaxPlugin_Hello extends TabaxPluginBase { } /// method 'connected' is defined in the TabaxPluginBase /// it is called after tabax have loaded the plugin and after setting /// the 'tabax' property of the plugin void connected() { ; // the utility macro #subscribe is defined in the TabaxPluginBase // when plugin is compiles, this code is substitutes by: // tabax.subscribe(methodStr(TabaxPluginBase, beforeStringInput), this); #subscribe(beforeStringInput) } /// This method will be called when user inputs a string in the edit control of /// Tabax. String inputed is in the _string parameter /// If plugin wants tabax not to perform the standard behavoiur, this method /// should return true boolean beforeStringInput(Tabax _tabax, str _string) { #define.prefix("hello ") // if _string starts with "hello " if (substr(_string, 1, strLen(#prefix))==#prefix) { // show greeting info("Hello, "+subStr(_string, strLen(#prefix)+1, strLen(_string) - strLen(#prefix))); // skip standard behavour return true; } // otherwise: pervorm standard behavour return false; }

