Custom handlers in Husky plugins must be prefixed with $ON_ and follow specific naming conventions based on their purpose:
- General Handlers: Use uppercase letters. Example:
$ON_MY_HANDLER. - Browser Event Handlers: For handlers that respond directly to passed-through browser events, start the name with
EVENT_. Example: $ON_EVENT_EDITING_AREA_KEYUP. - Message Handlers: For handlers that notify when a specific event has occurred (rather than performing a specific task), start the name with
MSG_. Example: $ON_MSG_EDITOR_READY.
Example: Implementing a custom action
To implement a custom action (like inserting a date):
- Initialize the target element in
_assignHTMLObjects. - Assign the event in
$ON_MSG_APP_READY using this.oApp.registerBrowserEvent(element, event, 'HANDLER_NAME'). - Define the handler as
$ON_HANDLER_NAME and use this.oApp.exec("PASTE_HTML", [content]) to insert content into the editor.
// 1. Assign event in $ON_MSG_APP_READY
this.oApp.registerBrowserEvent(this.oInputButton, 'click','PASTE_NOW_DATE');
// 2. Define the handler
$ON_PASTE_NOW_DATE : function(){
this.oApp.exec("PASTE_HTML", [new Date()]);
}