commit extjs-2.2.1
[extjs.git] / docs / output / Ext.Action.html
1         <div class="body-wrap">
2         <div class="top-tools">
3             <a class="inner-link" href="#Ext.Action-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
4             <a class="inner-link" href="#Ext.Action-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
5             <a class="inner-link" href="#Ext.Action-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
6                             <a class="inner-link" href="#Ext.Action-configs"><img src="../resources/images/default/s.gif" class="item-icon icon-config">Config Options</a>
7                         <a class="bookmark" href="../docs/?class=Ext.Action"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
8         </div>
9                 <h1>Class Ext.Action</h1>
10         <table cellspacing="0">
11             <tr><td class="label">Package:</td><td class="hd-info">Ext</td></tr>
12             <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/Action.js" target="_blank">Action.js</a></td></tr>
13             <tr><td class="label">Class:</td><td class="hd-info">Action</td></tr>
14                                     <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
15                     </table>
16         <div class="description">
17             *
18 <p>An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it
19 can be usefully shared among multiple components.  Actions let you share handlers, configuration options and UI
20 updates across any components that support the Action interface (primarily <a ext:cls="Ext.Toolbar" href="output/Ext.Toolbar.html">Ext.Toolbar</a>, <a ext:cls="Ext.Button" href="output/Ext.Button.html">Ext.Button</a>
21 and <a ext:cls="Ext.menu.Menu" href="output/Ext.menu.Menu.html">Ext.menu.Menu</a> components).</p>
22 <p>Aside from supporting the config object interface, any component that needs to use Actions must also support
23 the following method list, as these will be called as needed by the Action class: setText(string), setIconCls(string),
24 setDisabled(boolean), setVisible(boolean) and setHandler(function).</p>
25 Example usage:<br>
26 <pre><code><i>// Define the shared action.  Each component below will have the same</i>
27 <i>// display text and icon, and will display the same message on click.</i>
28 <b>var</b> action = <b>new</b> Ext.Action({
29     text: <em>'Do something'</em>,
30     handler: <b>function</b>(){
31         Ext.Msg.alert(<em>'Click'</em>, <em>'You did something.'</em>);
32     },
33     iconCls: <em>'<b>do</b>-something'</em>
34 });
35
36 <b>var</b> panel = <b>new</b> Ext.Panel({
37     title: <em>'Actions'</em>,
38     width:500,
39     height:300,
40     tbar: [
41         <i>// Add the action directly to a toolbar as a menu button</i>
42         action, {
43             text: <em>'Action Menu'</em>,
44             <i>// Add the action to a menu as a text item</i>
45             menu: [action]
46         }
47     ],
48     items: [
49         <i>// Add the action to the panel body as a standard button</i>
50         <b>new</b> Ext.Button(action)
51     ],
52     renderTo: Ext.getBody()
53 });
54
55 <i>// Change the text <b>for</b> all components using the action</i>
56 action.setText(<em>'Something <b>else</b>'</em>);</code></pre>        </div>
57         
58         <div class="hr"></div>
59                 <a id="Ext.Action-configs"></a>
60         <h2>Config Options</h2>
61         <table cellspacing="0" class="member-table">
62             <tr>
63                 <th class="sig-header" colspan="2">Config Options</th>
64                 <th class="msource-header">Defined By</th>
65             </tr>
66                 <tr class="config-row">\r
67         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
68         <td class="sig">\r
69         <a id="Ext.Action-disabled"></a>\r
70             <b>disabled</b> : Boolean            <div class="mdesc">\r
71                             True to disable all components using this action, false to enable them (defaults to false).                        </div>\r
72         </td>\r
73         <td class="msource">Action</td>\r
74     </tr>\r
75         <tr class="config-row alt expandable">\r
76         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
77         <td class="sig">\r
78         <a id="Ext.Action-handler"></a>\r
79             <b>handler</b> : Function            <div class="mdesc">\r
80                         <div class="short">The function that will be invoked by each component tied to this action when the component's primary event is trigger...</div>\r
81             <div class="long">\r
82                 The function that will be invoked by each component tied to this action when the component's primary event is triggered (defaults to undefined).            </div>\r
83                         </div>\r
84         </td>\r
85         <td class="msource">Action</td>\r
86     </tr>\r
87         <tr class="config-row">\r
88         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
89         <td class="sig">\r
90         <a id="Ext.Action-hidden"></a>\r
91             <b>hidden</b> : Boolean            <div class="mdesc">\r
92                             True to hide all components using this action, false to show them (defaults to false).                        </div>\r
93         </td>\r
94         <td class="msource">Action</td>\r
95     </tr>\r
96         <tr class="config-row alt expandable">\r
97         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
98         <td class="sig">\r
99         <a id="Ext.Action-iconCls"></a>\r
100             <b>iconCls</b> : String            <div class="mdesc">\r
101                         <div class="short">The icon CSS class for all components using this action (defaults to ''). The class should supply a background image ...</div>\r
102             <div class="long">\r
103                 The icon CSS class for all components using this action (defaults to ''). The class should supply a background image that will be used as the icon image.            </div>\r
104                         </div>\r
105         </td>\r
106         <td class="msource">Action</td>\r
107     </tr>\r
108         <tr class="config-row">\r
109         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
110         <td class="sig">\r
111         <a id="Ext.Action-scope"></a>\r
112             <b>scope</b> : Object            <div class="mdesc">\r
113                             The scope in which the <a ext:cls="Ext.Action" ext:member="handler" href="output/Ext.Action.html#handler">handler</a> function will execute.                        </div>\r
114         </td>\r
115         <td class="msource">Action</td>\r
116     </tr>\r
117         <tr class="config-row alt">\r
118         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
119         <td class="sig">\r
120         <a id="Ext.Action-text"></a>\r
121             <b>text</b> : String            <div class="mdesc">\r
122                             The text to set for all components using this action (defaults to '').                        </div>\r
123         </td>\r
124         <td class="msource">Action</td>\r
125     </tr>\r
126             </table>
127                 <a id="Ext.Action-props"></a>
128         <h2>Public Properties</h2>
129                 <table cellspacing="0" class="member-table">
130             <tr>
131                 <th class="sig-header" colspan="2">Property</th>
132                 <th class="msource-header">Defined By</th>
133             </tr>
134                 <tr class="property-row">\r
135         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
136         <td class="sig">\r
137         <a id="Ext.Action-isDisabled"></a>\r
138             <b>isDisabled</b> : Object            <div class="mdesc">\r
139                             Returns true if the components using this action are currently disabled, else returns false.  Read-only.                        </div>\r
140         </td>\r
141         <td class="msource">Action</td>\r
142     </tr>\r
143         <tr class="property-row alt">\r
144         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
145         <td class="sig">\r
146         <a id="Ext.Action-isHidden"></a>\r
147             <b>isHidden</b> : Object            <div class="mdesc">\r
148                             Returns true if the components using this action are currently hidden, else returns false.  Read-only.                        </div>\r
149         </td>\r
150         <td class="msource">Action</td>\r
151     </tr>\r
152             </table>
153                 <a id="Ext.Action-methods"></a>
154         <h2>Public Methods</h2>
155                 <table cellspacing="0" class="member-table">
156             <tr>
157                 <th class="sig-header" colspan="2">Method</th>
158                 <th class="msource-header">Defined By</th>
159             </tr>
160                 <tr class="method-row expandable">\r
161         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
162         <td class="sig">\r
163         <a id="Ext.Action-Action"></a>\r
164             <b>Action</b>(&nbsp;<code>Object config</code>&nbsp;)            <div class="mdesc">\r
165                         <div class="short"></div>\r
166             <div class="long">\r
167                     <div class="mdetail-params">\r
168         <strong>Parameters:</strong>\r
169         <ul><li><code>config</code> : Object<div class="sub-desc">The configuration options</div></li>        </ul>\r
170         <strong>Returns:</strong>\r
171         <ul>\r
172             <li><code></code></li>\r
173         </ul>\r
174     </div>\r
175                 </div>\r
176                         </div>\r
177         </td>\r
178         <td class="msource">Action</td>\r
179     </tr>\r
180         <tr class="method-row alt expandable">\r
181         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
182         <td class="sig">\r
183         <a id="Ext.Action-disable"></a>\r
184             <b>disable</b>() : void            <div class="mdesc">\r
185                         <div class="short">Disables all components using this action.</div>\r
186             <div class="long">\r
187                 Disables all components using this action.    <div class="mdetail-params">\r
188         <strong>Parameters:</strong>\r
189         <ul><li>None.</li>        </ul>\r
190         <strong>Returns:</strong>\r
191         <ul>\r
192             <li><code>void</code></li>\r
193         </ul>\r
194     </div>\r
195                 </div>\r
196                         </div>\r
197         </td>\r
198         <td class="msource">Action</td>\r
199     </tr>\r
200         <tr class="method-row expandable">\r
201         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
202         <td class="sig">\r
203         <a id="Ext.Action-each"></a>\r
204             <b>each</b>(&nbsp;<code>Function fn</code>, <code>Object scope</code>&nbsp;) : void            <div class="mdesc">\r
205                         <div class="short">Executes the specified function once for each component currently tied to this action.  The function passed
206 in should...</div>\r
207             <div class="long">\r
208                 Executes the specified function once for each component currently tied to this action.  The function passed
209 in should accept a single argument that will be an object that supports the basic Action config/method interface.    <div class="mdetail-params">\r
210         <strong>Parameters:</strong>\r
211         <ul><li><code>fn</code> : Function<div class="sub-desc">The function to execute for each component</div></li><li><code>scope</code> : Object<div class="sub-desc">The scope in which the function will execute</div></li>        </ul>\r
212         <strong>Returns:</strong>\r
213         <ul>\r
214             <li><code>void</code></li>\r
215         </ul>\r
216     </div>\r
217                 </div>\r
218                         </div>\r
219         </td>\r
220         <td class="msource">Action</td>\r
221     </tr>\r
222         <tr class="method-row alt expandable">\r
223         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
224         <td class="sig">\r
225         <a id="Ext.Action-enable"></a>\r
226             <b>enable</b>() : void            <div class="mdesc">\r
227                         <div class="short">Enables all components using this action.</div>\r
228             <div class="long">\r
229                 Enables all components using this action.    <div class="mdetail-params">\r
230         <strong>Parameters:</strong>\r
231         <ul><li>None.</li>        </ul>\r
232         <strong>Returns:</strong>\r
233         <ul>\r
234             <li><code>void</code></li>\r
235         </ul>\r
236     </div>\r
237                 </div>\r
238                         </div>\r
239         </td>\r
240         <td class="msource">Action</td>\r
241     </tr>\r
242         <tr class="method-row expandable">\r
243         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
244         <td class="sig">\r
245         <a id="Ext.Action-execute"></a>\r
246             <b>execute</b>(&nbsp;<span class="optional" title="Optional">[<code>Mixed arg1</code>]</span>, <span class="optional" title="Optional">[<code>Mixed arg2</code>]</span>, <span class="optional" title="Optional">[<code>Mixed etc...</code>]</span>&nbsp;) : void            <div class="mdesc">\r
247                         <div class="short">Executes this action manually using the default handler specified in the original config object.  Any arguments
248 passe...</div>\r
249             <div class="long">\r
250                 Executes this action manually using the default handler specified in the original config object.  Any arguments
251 passed to this function will be passed on to the handler function.    <div class="mdetail-params">\r
252         <strong>Parameters:</strong>\r
253         <ul><li><code>arg1</code> : Mixed<div class="sub-desc">(optional) Variable number of arguments passed to the handler function</div></li><li><code>arg2</code> : Mixed<div class="sub-desc">(optional)</div></li><li><code>etc...</code> : Mixed<div class="sub-desc">(optional)</div></li>        </ul>\r
254         <strong>Returns:</strong>\r
255         <ul>\r
256             <li><code>void</code></li>\r
257         </ul>\r
258     </div>\r
259                 </div>\r
260                         </div>\r
261         </td>\r
262         <td class="msource">Action</td>\r
263     </tr>\r
264         <tr class="method-row alt expandable">\r
265         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
266         <td class="sig">\r
267         <a id="Ext.Action-getIconClass"></a>\r
268             <b>getIconClass</b>() : void            <div class="mdesc">\r
269                         <div class="short">Gets the icon CSS class currently used by all components using this action.</div>\r
270             <div class="long">\r
271                 Gets the icon CSS class currently used by all components using this action.    <div class="mdetail-params">\r
272         <strong>Parameters:</strong>\r
273         <ul><li>None.</li>        </ul>\r
274         <strong>Returns:</strong>\r
275         <ul>\r
276             <li><code>void</code></li>\r
277         </ul>\r
278     </div>\r
279                 </div>\r
280                         </div>\r
281         </td>\r
282         <td class="msource">Action</td>\r
283     </tr>\r
284         <tr class="method-row expandable">\r
285         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
286         <td class="sig">\r
287         <a id="Ext.Action-getText"></a>\r
288             <b>getText</b>() : void            <div class="mdesc">\r
289                         <div class="short">Gets the text currently displayed by all components using this action.</div>\r
290             <div class="long">\r
291                 Gets the text currently displayed by all components using this action.    <div class="mdetail-params">\r
292         <strong>Parameters:</strong>\r
293         <ul><li>None.</li>        </ul>\r
294         <strong>Returns:</strong>\r
295         <ul>\r
296             <li><code>void</code></li>\r
297         </ul>\r
298     </div>\r
299                 </div>\r
300                         </div>\r
301         </td>\r
302         <td class="msource">Action</td>\r
303     </tr>\r
304         <tr class="method-row alt expandable">\r
305         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
306         <td class="sig">\r
307         <a id="Ext.Action-hide"></a>\r
308             <b>hide</b>() : void            <div class="mdesc">\r
309                         <div class="short">Hides all components using this action.</div>\r
310             <div class="long">\r
311                 Hides all components using this action.    <div class="mdetail-params">\r
312         <strong>Parameters:</strong>\r
313         <ul><li>None.</li>        </ul>\r
314         <strong>Returns:</strong>\r
315         <ul>\r
316             <li><code>void</code></li>\r
317         </ul>\r
318     </div>\r
319                 </div>\r
320                         </div>\r
321         </td>\r
322         <td class="msource">Action</td>\r
323     </tr>\r
324         <tr class="method-row expandable">\r
325         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
326         <td class="sig">\r
327         <a id="Ext.Action-setDisabled"></a>\r
328             <b>setDisabled</b>(&nbsp;<code>Boolean disabled</code>&nbsp;) : void            <div class="mdesc">\r
329                         <div class="short">Sets the disabled state of all components using this action.  Shortcut method
330 for <a ext:cls="Ext.Action" ext:member="enable" href="output/Ext.Action.html#enable">enable</a> and <a ext:cls="Ext.Action" ext:member="disable" href="output/Ext.Action.html#disable">disable</a>.</div>\r
331             <div class="long">\r
332                 Sets the disabled state of all components using this action.  Shortcut method
333 for <a ext:cls="Ext.Action" ext:member="enable" href="output/Ext.Action.html#enable">enable</a> and <a ext:cls="Ext.Action" ext:member="disable" href="output/Ext.Action.html#disable">disable</a>.    <div class="mdetail-params">\r
334         <strong>Parameters:</strong>\r
335         <ul><li><code>disabled</code> : Boolean<div class="sub-desc">True to disable the component, false to enable it</div></li>        </ul>\r
336         <strong>Returns:</strong>\r
337         <ul>\r
338             <li><code>void</code></li>\r
339         </ul>\r
340     </div>\r
341                 </div>\r
342                         </div>\r
343         </td>\r
344         <td class="msource">Action</td>\r
345     </tr>\r
346         <tr class="method-row alt expandable">\r
347         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
348         <td class="sig">\r
349         <a id="Ext.Action-setHandler"></a>\r
350             <b>setHandler</b>(&nbsp;<code>Function fn</code>, <code>Object scope</code>&nbsp;) : void            <div class="mdesc">\r
351                         <div class="short">Sets the function that will be called by each component using this action when its primary event is triggered.</div>\r
352             <div class="long">\r
353                 Sets the function that will be called by each component using this action when its primary event is triggered.    <div class="mdetail-params">\r
354         <strong>Parameters:</strong>\r
355         <ul><li><code>fn</code> : Function<div class="sub-desc">The function that will be invoked by the action's components. The function
356 will be called with no arguments.</div></li><li><code>scope</code> : Object<div class="sub-desc">The scope in which the function will execute</div></li>        </ul>\r
357         <strong>Returns:</strong>\r
358         <ul>\r
359             <li><code>void</code></li>\r
360         </ul>\r
361     </div>\r
362                 </div>\r
363                         </div>\r
364         </td>\r
365         <td class="msource">Action</td>\r
366     </tr>\r
367         <tr class="method-row expandable">\r
368         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
369         <td class="sig">\r
370         <a id="Ext.Action-setHidden"></a>\r
371             <b>setHidden</b>(&nbsp;<code>Boolean hidden</code>&nbsp;) : void            <div class="mdesc">\r
372                         <div class="short">Sets the hidden state of all components using this action.  Shortcut method
373 for <a ext:cls="Ext.Action" ext:member="hide" href="output/Ext.Action.html#hide">hide</a> and <a ext:cls="Ext.Action" ext:member="show" href="output/Ext.Action.html#show">show</a>.</div>\r
374             <div class="long">\r
375                 Sets the hidden state of all components using this action.  Shortcut method
376 for <a ext:cls="Ext.Action" ext:member="hide" href="output/Ext.Action.html#hide">hide</a> and <a ext:cls="Ext.Action" ext:member="show" href="output/Ext.Action.html#show">show</a>.    <div class="mdetail-params">\r
377         <strong>Parameters:</strong>\r
378         <ul><li><code>hidden</code> : Boolean<div class="sub-desc">True to hide the component, false to show it</div></li>        </ul>\r
379         <strong>Returns:</strong>\r
380         <ul>\r
381             <li><code>void</code></li>\r
382         </ul>\r
383     </div>\r
384                 </div>\r
385                         </div>\r
386         </td>\r
387         <td class="msource">Action</td>\r
388     </tr>\r
389         <tr class="method-row alt expandable">\r
390         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
391         <td class="sig">\r
392         <a id="Ext.Action-setIconClass"></a>\r
393             <b>setIconClass</b>(&nbsp;<code>String cls</code>&nbsp;) : void            <div class="mdesc">\r
394                         <div class="short">Sets the icon CSS class for all components using this action.  The class should supply
395 a background image that will b...</div>\r
396             <div class="long">\r
397                 Sets the icon CSS class for all components using this action.  The class should supply
398 a background image that will be used as the icon image.    <div class="mdetail-params">\r
399         <strong>Parameters:</strong>\r
400         <ul><li><code>cls</code> : String<div class="sub-desc">The CSS class supplying the icon image</div></li>        </ul>\r
401         <strong>Returns:</strong>\r
402         <ul>\r
403             <li><code>void</code></li>\r
404         </ul>\r
405     </div>\r
406                 </div>\r
407                         </div>\r
408         </td>\r
409         <td class="msource">Action</td>\r
410     </tr>\r
411         <tr class="method-row expandable">\r
412         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
413         <td class="sig">\r
414         <a id="Ext.Action-setText"></a>\r
415             <b>setText</b>(&nbsp;<code>String text</code>&nbsp;) : void            <div class="mdesc">\r
416                         <div class="short">Sets the text to be displayed by all components using this action.</div>\r
417             <div class="long">\r
418                 Sets the text to be displayed by all components using this action.    <div class="mdetail-params">\r
419         <strong>Parameters:</strong>\r
420         <ul><li><code>text</code> : String<div class="sub-desc">The text to display</div></li>        </ul>\r
421         <strong>Returns:</strong>\r
422         <ul>\r
423             <li><code>void</code></li>\r
424         </ul>\r
425     </div>\r
426                 </div>\r
427                         </div>\r
428         </td>\r
429         <td class="msource">Action</td>\r
430     </tr>\r
431         <tr class="method-row alt expandable">\r
432         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
433         <td class="sig">\r
434         <a id="Ext.Action-show"></a>\r
435             <b>show</b>() : void            <div class="mdesc">\r
436                         <div class="short">Shows all components using this action.</div>\r
437             <div class="long">\r
438                 Shows all components using this action.    <div class="mdetail-params">\r
439         <strong>Parameters:</strong>\r
440         <ul><li>None.</li>        </ul>\r
441         <strong>Returns:</strong>\r
442         <ul>\r
443             <li><code>void</code></li>\r
444         </ul>\r
445     </div>\r
446                 </div>\r
447                         </div>\r
448         </td>\r
449         <td class="msource">Action</td>\r
450     </tr>\r
451             </table>
452                 <a id="Ext.Action-events"></a>
453         <h2>Public Events</h2>
454         <div class="no-members">This class has no public events.</div>
455         </div>