2d0c9b504072911ed688315ef5ffb3ee5512d63d.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <div class="body-wrap">
  2. <div class="top-tools">
  3. <a class="inner-link" href="#Ext.util.Observable-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
  4. <a class="inner-link" href="#Ext.util.Observable-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
  5. <a class="inner-link" href="#Ext.util.Observable-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
  6. <a class="inner-link" href="#Ext.util.Observable-configs"><img src="../resources/images/default/s.gif" class="item-icon icon-config">Config Options</a>
  7. <a class="bookmark" href="../docs/?class=Ext.util.Observable"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
  8. </div>
  9. <h1>Class Ext.util.Observable</h1>
  10. <table cellspacing="0">
  11. <tr><td class="label">Package:</td><td class="hd-info">Ext.util</td></tr>
  12. <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/Observable.js" target="_blank">Observable.js</a></td></tr>
  13. <tr><td class="label">Class:</td><td class="hd-info">Observable</td></tr>
  14. <tr><td class="label">Subclasses:</td><td class="hd-info"><a ext:cls="Ext.Component" href="output/Ext.Component.html">Component</a>, <a ext:cls="Ext.Resizable" href="output/Ext.Resizable.html">Resizable</a>, <a ext:cls="Ext.SplitBar" href="output/Ext.SplitBar.html">SplitBar</a>, <a ext:cls="Ext.Updater" href="output/Ext.Updater.html">Updater</a>, <a ext:cls="Ext.data.Connection" href="output/Ext.data.Connection.html">Connection</a>, <a ext:cls="Ext.data.DataProxy" href="output/Ext.data.DataProxy.html">DataProxy</a>, <a ext:cls="Ext.data.Node" href="output/Ext.data.Node.html">Node</a>, <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Store</a>, <a ext:cls="Ext.data.Tree" href="output/Ext.data.Tree.html">Tree</a>, <a ext:cls="Ext.form.BasicForm" href="output/Ext.form.BasicForm.html">BasicForm</a>, <a ext:cls="Ext.grid.AbstractSelectionModel" href="output/Ext.grid.AbstractSelectionModel.html">AbstractSelectionModel</a>, <a ext:cls="Ext.grid.ColumnModel" href="output/Ext.grid.ColumnModel.html">ColumnModel</a>, <a ext:cls="Ext.grid.GridView" href="output/Ext.grid.GridView.html">GridView</a>, <a ext:cls="Ext.grid.PropertyStore" href="output/Ext.grid.PropertyStore.html">PropertyStore</a>, <a ext:cls="Ext.menu.Menu" href="output/Ext.menu.Menu.html">Menu</a>, <a ext:cls="Ext.tree.DefaultSelectionModel" href="output/Ext.tree.DefaultSelectionModel.html">DefaultSelectionModel</a>, <a ext:cls="Ext.tree.MultiSelectionModel" href="output/Ext.tree.MultiSelectionModel.html">MultiSelectionModel</a>, <a ext:cls="Ext.tree.TreeLoader" href="output/Ext.tree.TreeLoader.html">TreeLoader</a>, <a ext:cls="Ext.util.ClickRepeater" href="output/Ext.util.ClickRepeater.html">ClickRepeater</a>, <a ext:cls="Ext.util.MixedCollection" href="output/Ext.util.MixedCollection.html">MixedCollection</a></td></tr>
  15. <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
  16. </table>
  17. <div class="description">
  18. Abstract base class that provides a common interface for publishing events. Subclasses are expected to
  19. to have a property "events" with all the events defined.<br>
  20. For example:
  21. <pre><code>Employee = <b>function</b>(name){
  22. <b>this</b>.name = name;
  23. <b>this</b>.addEvents({
  24. <em>"fired"</em> : true,
  25. <em>"quit"</em> : true
  26. });
  27. }
  28. Ext.extend(Employee, Ext.util.Observable);</code></pre> </div>
  29. <div class="hr"></div>
  30. <a id="Ext.util.Observable-configs"></a>
  31. <h2>Config Options</h2>
  32. <table cellspacing="0" class="member-table">
  33. <tr>
  34. <th class="sig-header" colspan="2">Config Options</th>
  35. <th class="msource-header">Defined By</th>
  36. </tr>
  37. <tr class="config-row expandable">
  38. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  39. <td class="sig">
  40. <a id="Ext.util.Observable-listeners"></a>
  41. <b>listeners</b> : Object <div class="mdesc">
  42. <div class="short">A config object containing one or more event handlers to be added to this object during initialization. This should b...</div>
  43. <div class="long">
  44. A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the <a ext:cls="Ext.util.Observable" ext:member="addListener" href="output/Ext.util.Observable.html#addListener">addListener</a> example for attaching multiple handlers at once. </div>
  45. </div>
  46. </td>
  47. <td class="msource">Observable</td>
  48. </tr>
  49. </table>
  50. <a id="Ext.util.Observable-props"></a>
  51. <h2>Public Properties</h2>
  52. <div class="no-members">This class has no public properties.</div> <a id="Ext.util.Observable-methods"></a>
  53. <h2>Public Methods</h2>
  54. <table cellspacing="0" class="member-table">
  55. <tr>
  56. <th class="sig-header" colspan="2">Method</th>
  57. <th class="msource-header">Defined By</th>
  58. </tr>
  59. <tr class="method-row expandable">
  60. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  61. <td class="sig">
  62. <a id="Ext.util.Observable-Observable.capture"></a>
  63. <b>Observable.capture</b>(&nbsp;<code>Observable o</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void <div class="mdesc">
  64. <div class="short">&lt;static&gt; Starts capture on the specified Observable. All events will be passed
  65. to the supplied function with th...</div>
  66. <div class="long">
  67. &lt;static&gt; Starts capture on the specified Observable. All events will be passed
  68. to the supplied function with the event name + standard signature of the event
  69. <b>before</b> the event is fired. If the supplied function returns false,
  70. the event will not fire. <div class="mdetail-params">
  71. <strong>Parameters:</strong>
  72. <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to capture</div></li><li><code>fn</code> : Function<div class="sub-desc">The function to call</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the fn</div></li> </ul>
  73. <strong>Returns:</strong>
  74. <ul>
  75. <li><code>void</code></li>
  76. </ul>
  77. </div>
  78. </div>
  79. </div>
  80. </td>
  81. <td class="msource">Observable</td>
  82. </tr>
  83. <tr class="method-row alt expandable">
  84. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  85. <td class="sig">
  86. <a id="Ext.util.Observable-Observable.releaseCapture"></a>
  87. <b>Observable.releaseCapture</b>(&nbsp;<code>Observable o</code>&nbsp;) : void <div class="mdesc">
  88. <div class="short">&lt;static&gt; Removes <b>all</b> added captures from the Observable.</div>
  89. <div class="long">
  90. &lt;static&gt; Removes <b>all</b> added captures from the Observable. <div class="mdetail-params">
  91. <strong>Parameters:</strong>
  92. <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to release</div></li> </ul>
  93. <strong>Returns:</strong>
  94. <ul>
  95. <li><code>void</code></li>
  96. </ul>
  97. </div>
  98. </div>
  99. </div>
  100. </td>
  101. <td class="msource">Observable</td>
  102. </tr>
  103. <tr class="method-row expandable">
  104. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  105. <td class="sig">
  106. <a id="Ext.util.Observable-addEvents"></a>
  107. <b>addEvents</b>(&nbsp;<code>Object object</code>&nbsp;) : void <div class="mdesc">
  108. <div class="short">Used to define events on this Observable</div>
  109. <div class="long">
  110. Used to define events on this Observable <div class="mdetail-params">
  111. <strong>Parameters:</strong>
  112. <ul><li><code>object</code> : Object<div class="sub-desc">The object with the events defined</div></li> </ul>
  113. <strong>Returns:</strong>
  114. <ul>
  115. <li><code>void</code></li>
  116. </ul>
  117. </div>
  118. </div>
  119. </div>
  120. </td>
  121. <td class="msource">Observable</td>
  122. </tr>
  123. <tr class="method-row alt expandable">
  124. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  125. <td class="sig">
  126. <a id="Ext.util.Observable-addListener"></a>
  127. <b>addListener</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;) : void <div class="mdesc">
  128. <div class="short">Appends an event handler to this component</div>
  129. <div class="long">
  130. Appends an event handler to this component <div class="mdetail-params">
  131. <strong>Parameters:</strong>
  132. <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
  133. function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional) An object containing handler configuration
  134. properties. This may contain any of the following properties:<ul>
  135. <li><b>scope</b> : Object<p class="sub-desc">The scope in which to execute the handler function. The handler function's "this" context.</p></li>
  136. <li><b>delay</b> : Number<p class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</p></li>
  137. <li><b>single</b> : Boolean<p class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</p></li>
  138. <li>buffer {Number} Causes the handler to be scheduled to run in an <a ext:cls="Ext.util.DelayedTask" href="output/Ext.util.DelayedTask.html">Ext.util.DelayedTask</a> delayed
  139. by the specified number of milliseconds. If the event fires again within that time, the original
  140. handler is <em>not</em> invoked, but the new handler is scheduled in its place.</li>
  141. </ul><br>
  142. <p>
  143. <b>Combining Options</b><br>
  144. Using the options argument, it is possible to combine different types of listeners:<br>
  145. <br>
  146. A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
  147. <pre><code>el.on(<em>'click'</em>, <b>this</b>.onClick, <b>this</b>, {
  148. single: true,
  149. delay: 100,
  150. forumId: 4
  151. });</code></pre>
  152. <p>
  153. <b>Attaching multiple handlers in 1 call</b><br>
  154. The method also allows for a single argument to be passed which is a config object containing properties
  155. which specify multiple handlers.
  156. <p>
  157. <pre><code>foo.on({
  158. <em>'click'</em> : {
  159. fn: <b>this</b>.onClick,
  160. scope: <b>this</b>,
  161. delay: 100
  162. },
  163. <em>'mouseover'</em> : {
  164. fn: <b>this</b>.onMouseOver,
  165. scope: <b>this</b>
  166. },
  167. <em>'mouseout'</em> : {
  168. fn: <b>this</b>.onMouseOut,
  169. scope: <b>this</b>
  170. }
  171. });</code></pre>
  172. <p>
  173. Or a shorthand syntax:<br>
  174. <pre><code>foo.on({
  175. <em>'click'</em> : <b>this</b>.onClick,
  176. <em>'mouseover'</em> : <b>this</b>.onMouseOver,
  177. <em>'mouseout'</em> : <b>this</b>.onMouseOut,
  178. scope: <b>this</b>
  179. });</code></pre></div></li> </ul>
  180. <strong>Returns:</strong>
  181. <ul>
  182. <li><code>void</code></li>
  183. </ul>
  184. </div>
  185. </div>
  186. </div>
  187. </td>
  188. <td class="msource">Observable</td>
  189. </tr>
  190. <tr class="method-row expandable">
  191. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  192. <td class="sig">
  193. <a id="Ext.util.Observable-fireEvent"></a>
  194. <b>fireEvent</b>(&nbsp;<code>String eventName</code>, <code>Object... args</code>&nbsp;) : Boolean <div class="mdesc">
  195. <div class="short">Fires the specified event with the passed parameters (minus the event name).</div>
  196. <div class="long">
  197. Fires the specified event with the passed parameters (minus the event name). <div class="mdetail-params">
  198. <strong>Parameters:</strong>
  199. <ul><li><code>eventName</code> : String<div class="sub-desc"></div></li><li><code>args</code> : Object...<div class="sub-desc">Variable number of parameters are passed to handlers</div></li> </ul>
  200. <strong>Returns:</strong>
  201. <ul>
  202. <li><code>Boolean</code><div class="sub-desc">returns false if any of the handlers return false otherwise it returns true</div></li>
  203. </ul>
  204. </div>
  205. </div>
  206. </div>
  207. </td>
  208. <td class="msource">Observable</td>
  209. </tr>
  210. <tr class="method-row alt expandable">
  211. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  212. <td class="sig">
  213. <a id="Ext.util.Observable-hasListener"></a>
  214. <b>hasListener</b>(&nbsp;<code>String eventName</code>&nbsp;) : Boolean <div class="mdesc">
  215. <div class="short">Checks to see if this object has any listeners for a specified event</div>
  216. <div class="long">
  217. Checks to see if this object has any listeners for a specified event <div class="mdetail-params">
  218. <strong>Parameters:</strong>
  219. <ul><li><code>eventName</code> : String<div class="sub-desc">The name of the event to check for</div></li> </ul>
  220. <strong>Returns:</strong>
  221. <ul>
  222. <li><code>Boolean</code><div class="sub-desc">True if the event is being listened for, else false</div></li>
  223. </ul>
  224. </div>
  225. </div>
  226. </div>
  227. </td>
  228. <td class="msource">Observable</td>
  229. </tr>
  230. <tr class="method-row expandable">
  231. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  232. <td class="sig">
  233. <a id="Ext.util.Observable-on"></a>
  234. <b>on</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;) : void <div class="mdesc">
  235. <div class="short">Appends an event handler to this element (shorthand for addListener)</div>
  236. <div class="long">
  237. Appends an event handler to this element (shorthand for addListener) <div class="mdetail-params">
  238. <strong>Parameters:</strong>
  239. <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
  240. function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional)</div></li> </ul>
  241. <strong>Returns:</strong>
  242. <ul>
  243. <li><code>void</code></li>
  244. </ul>
  245. </div>
  246. </div>
  247. </div>
  248. </td>
  249. <td class="msource">Observable</td>
  250. </tr>
  251. <tr class="method-row alt expandable">
  252. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  253. <td class="sig">
  254. <a id="Ext.util.Observable-purgeListeners"></a>
  255. <b>purgeListeners</b>() : void <div class="mdesc">
  256. <div class="short">Removes all listeners for this object</div>
  257. <div class="long">
  258. Removes all listeners for this object <div class="mdetail-params">
  259. <strong>Parameters:</strong>
  260. <ul><li>None.</li> </ul>
  261. <strong>Returns:</strong>
  262. <ul>
  263. <li><code>void</code></li>
  264. </ul>
  265. </div>
  266. </div>
  267. </div>
  268. </td>
  269. <td class="msource">Observable</td>
  270. </tr>
  271. <tr class="method-row expandable">
  272. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  273. <td class="sig">
  274. <a id="Ext.util.Observable-removeListener"></a>
  275. <b>removeListener</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void <div class="mdesc">
  276. <div class="short">Removes a listener</div>
  277. <div class="long">
  278. Removes a listener <div class="mdetail-params">
  279. <strong>Parameters:</strong>
  280. <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li> </ul>
  281. <strong>Returns:</strong>
  282. <ul>
  283. <li><code>void</code></li>
  284. </ul>
  285. </div>
  286. </div>
  287. </div>
  288. </td>
  289. <td class="msource">Observable</td>
  290. </tr>
  291. <tr class="method-row alt expandable">
  292. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  293. <td class="sig">
  294. <a id="Ext.util.Observable-resumeEvents"></a>
  295. <b>resumeEvents</b>() : void <div class="mdesc">
  296. <div class="short">Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>)</div>
  297. <div class="long">
  298. Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>) <div class="mdetail-params">
  299. <strong>Parameters:</strong>
  300. <ul><li>None.</li> </ul>
  301. <strong>Returns:</strong>
  302. <ul>
  303. <li><code>void</code></li>
  304. </ul>
  305. </div>
  306. </div>
  307. </div>
  308. </td>
  309. <td class="msource">Observable</td>
  310. </tr>
  311. <tr class="method-row expandable">
  312. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  313. <td class="sig">
  314. <a id="Ext.util.Observable-suspendEvents"></a>
  315. <b>suspendEvents</b>() : void <div class="mdesc">
  316. <div class="short">Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>)</div>
  317. <div class="long">
  318. Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>) <div class="mdetail-params">
  319. <strong>Parameters:</strong>
  320. <ul><li>None.</li> </ul>
  321. <strong>Returns:</strong>
  322. <ul>
  323. <li><code>void</code></li>
  324. </ul>
  325. </div>
  326. </div>
  327. </div>
  328. </td>
  329. <td class="msource">Observable</td>
  330. </tr>
  331. <tr class="method-row alt expandable">
  332. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  333. <td class="sig">
  334. <a id="Ext.util.Observable-un"></a>
  335. <b>un</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void <div class="mdesc">
  336. <div class="short">Removes a listener (shorthand for removeListener)</div>
  337. <div class="long">
  338. Removes a listener (shorthand for removeListener) <div class="mdetail-params">
  339. <strong>Parameters:</strong>
  340. <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li> </ul>
  341. <strong>Returns:</strong>
  342. <ul>
  343. <li><code>void</code></li>
  344. </ul>
  345. </div>
  346. </div>
  347. </div>
  348. </td>
  349. <td class="msource">Observable</td>
  350. </tr>
  351. </table>
  352. <a id="Ext.util.Observable-events"></a>
  353. <h2>Public Events</h2>
  354. <div class="no-members">This class has no public events.</div>
  355. </div>