1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
2 <html xmlns="http://www.w3.org/1999/xhtml">
\r
5 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
\r
8 <title>notifiers</title>
\r
14 <p>BlueGriffon provides extension developers with an object allowing to register listeners for any kind of events. This object is NotifierUtils:</p>
\r
15 <h4>Register a BlueGriffon event callback</h4>
\r
16 <table style="text-align: left;" class="methodTable" border="1" cellpadding="2" cellspacing="2">
\r
22 <th>Method name</th>
\r
25 <td><code>addNotifierCallback</code></td>
\r
38 <li><code>aEventName,</code> a string representing the event</li>
\r
39 <li><code>aListener</code>, a function</li>
\r
40 <li><code>aContext</code>, an object to be user in the listener as local context</li>
\r
50 <th>Return value</th>
\r
53 <td>no return value ; dumps an error on console if listener cannot be registered</td>
\r
61 <h4>Dispatch a BlueGriffon event</h4>
\r
62 <p>To dispatch an event use the following method:</p>
\r
63 <table style="text-align: left;" class="methodTable" border="1" cellpadding="2" cellspacing="2">
\r
69 <th>Method name</th>
\r
72 <td><code>notify</code></td>
\r
85 <li><code>aEventName,</code> a string representing the event<span style="font-family: monospace;"></span></li>
\r
86 <li>all other arguments will be passed to the listeners for this event</li>
\r
96 <th>Return value</th>
\r
99 <td>no return value ; dumps an error on console if no event of that name is registered or if a listener throws an exception</td>
\r
107 <h4>Remove a BlueGriffon event callback</h4>
\r
108 <table style="text-align: left;" class="methodTable" border="1" cellpadding="2" cellspacing="2">
\r
114 <th>Method name</th>
\r
117 <td><code>removeNotifierCallback</code></td>
\r
124 <th>Parameters</th>
\r
130 <li><code>aEventName,</code> a string representing the event</li>
\r
131 <li><code>aListener</code>, a function</li>
\r
141 <th>Return value</th>
\r
144 <td>no return value ; dumps an error on console if
\r
145 no event of that name is registered or if that listener is not
\r
146 registered as callback for that event name</td>
\r
154 <h4>Clean all BlueGriffon event callback for a given event name</h4>
\r
155 <table style="text-align: left;" class="methodTable" border="1" cellpadding="2" cellspacing="2">
\r
161 <th>Method name</th>
\r
164 <td><code>cleanNotifier</code></td>
\r
171 <th>Parameters</th>
\r
177 <li><code>aEventName,</code> a string representing the event<span style="font-family: monospace;"></span></li>
\r
187 <th>Return value</th>
\r
190 <td>no return value</td>
\r
199 <pre>var EditorScrolledNotifier = {<br /> startup: function EditorScrolledNotifier_startup()<br /> {<br /> var tabeditor = document.getElementById("tabeditor");<br /> tabeditor.addEventListener("scroll", this.onEditorScrolled, false);<br /> },<br /><br /> shutdown: function EditorScrolledNotifier_shutdown()<br /> {<br /> var tabeditor = document.getElementById("tabeditor");<br /> tabeditor.removeEventListener("scroll", this.onEditorScrolled, false);<br /> },<br /><br /> onEditorScrolled: function EditorScrolledNotifier_onEditorScrolled(aEvent)<br /> {<br /> NotifierUtils.notify("editorScrolled", EditorUtils.getCurrentEditorElement());<br /> }<br />};<br /><br />EditorScrolledNotifier .startup();<br /><br />.....<br /><br /> <constructor><br /> <![CDATA[<br /> NotifierUtils.addNotifierCallback("editorScrolled", this.onEditorScrolled, this);<br /> ]]><br /> </constructor><br /><br /> <destructor><br /> <![CDATA[<br /> NotifierUtils.removeNotifierCallback("editorScrolled", this.onEditorScrolled);<br /> ]]><br /> </destructor><br /><br /> <method name="onEditorScrolled"><br /> <param name="aEditor"/><br /> <body><br /> <![CDATA[<br /> var elt = this.getSelectionForEditor(aEditor);<br /> this.refreshRulerForElement(elt);<br /> ]]><br /> </body><br /> </method></pre>
\r