webgui/www/extras/yui/docs/YAHOO.util.CustomEvent.html
JT Smith 20f8df1291 upgrading to YUI 2.6
data tables are going to need some work yet, but the other stuff seems to be working 100%
2008-10-22 23:53:29 +00:00

839 lines
38 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>API: event YAHOO.util.CustomEvent (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/api.css">
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
<h3>Event Utility&nbsp; <span class="subtitle">2.6.0</span></h3>
<p>
<a href="./index.html">Yahoo! UI Library</a>
&gt; <a href="./module_event.html">event</a>
&gt; YAHOO.util.CustomEvent
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
</form>
<h2>
Class <b>YAHOO.util.CustomEvent</b>
<span class="extends">
</span>
<span class="extends">
</span>
</code>
</h2>
<!-- class tree goes here -->
<div class="summary description">
The CustomEvent class lets you define events for your application
that can be subscribed to by one or more independent component.
</div>
<div class="section constructor details">
<h3 id="constructor">Constructor</h3>
<div class="content">
<div class="detail">
<strong>YAHOO.util.CustomEvent</strong>
<code>
(
type
,
oScope
,
silent
,
signature
)
</code>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>type
&lt;String&gt;
</code>
The type of event, which is passed to the callback
when the event fires
</dd>
<dd>
<code>oScope
&lt;Object&gt;
</code>
The context the event will fire from. "this" will
refer to this object in the callback. Default value:
the window object. The listener can override this.
</dd>
<dd>
<code>silent
&lt;boolean&gt;
</code>
pass true to prevent the event from writing to
the debugsystem
</dd>
<dd>
<code>signature
&lt;int&gt;
</code>
the signature that the custom event subscriber
will receive. YAHOO.util.CustomEvent.LIST or
YAHOO.util.CustomEvent.FLAT. The default is
YAHOO.util.CustomEvent.LIST.
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="section field details">
<h3 id="properties">Properties</h3>
<div class="content">
<div class="">
<h4><a name="property_lastError">lastError</a>
<code>- Error</code>
</h4>
<div class="detail">
<div class="description">
In order to make it possible to execute the rest of the subscriber
stack when one thows an exception, the subscribers exceptions are
caught. The most recent exception is stored in this property
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_scope">scope</a>
<code>- object</code>
</h4>
<div class="detail">
<div class="description">
The scope the the event will fire from by default. Defaults to the window
obj
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_signature">signature</a>
<code>- int</code>
</h4>
<div class="detail">
<div class="description">
Custom events support two styles of arguments provided to the event
subscribers.
<ul>
<li>YAHOO.util.CustomEvent.LIST:
<ul>
<li>param1: event name</li>
<li>param2: array of arguments sent to fire</li>
<li>param3: <optional> a custom object supplied by the subscriber</li>
</ul>
</li>
<li>YAHOO.util.CustomEvent.FLAT
<ul>
<li>param1: the first argument passed to fire. If you need to
pass multiple parameters, use and array or object literal</li>
<li>param2: <optional> a custom object supplied by the subscriber</li>
</ul>
</li>
</ul>
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_silent">silent</a>
<code>- boolean</code>
</h4>
<div class="detail">
<div class="description">
By default all custom events are logged in the debug build, set silent
to true to disable debug outpu for this event.
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_subscribers">subscribers</a>
<code>- Subscriber[]</code>
</h4>
<div class="detail">
<div class="description">
The subscribers to this event
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_type">type</a>
<code>- string</code>
</h4>
<div class="detail">
<div class="description">
The type of event, returned to subscribers when the event fires
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_YAHOO.util.CustomEvent.FLAT">YAHOO.util.CustomEvent.FLAT</a>
<code>- static int</code>
</h4>
<div class="detail">
<div class="description">
Subscriber listener sigature constant. The FLAT type returns two
parameters: the first argument passed to fire and the optional
custom object
</div>
</div>
<hr />
</div>
<div class="">
<h4><a name="property_YAHOO.util.CustomEvent.LIST">YAHOO.util.CustomEvent.LIST</a>
<code>- static int</code>
</h4>
<div class="detail">
<div class="description">
Subscriber listener sigature constant. The LIST type returns three
parameters: the event type, the array of args passed to fire, and
the optional custom object
</div>
</div>
<hr />
</div>
</div>
</div>
<div class="section method details">
<h3 id="methods">Methods</h3>
<div class="content">
<div class="private">
<h4>
<a name="method__delete">_delete</a></h4>
<div class="detail">
<code>
private
void
<strong>_delete</strong>
(
)
</code>
<div class="description">
</div>
<div class="description">
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_fire">fire</a></h4>
<div class="detail">
<code>
boolean
<strong>fire</strong>
(
arguments
)
</code>
<div class="description">
Notifies the subscribers. The callback functions will be executed
from the scope specified when the event was created, and with the
following parameters:
<ul>
<li>The type of event</li>
<li>All of the arguments fire() was executed with as an array</li>
<li>The custom object (if any) that was passed into the subscribe()
method</li>
</ul>
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>arguments &lt;Object*&gt;</code>
an arbitrary set of parameters to pass to
the handler.
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>false if one of the subscribers returned false,
true otherwise</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_subscribe">subscribe</a></h4>
<div class="detail">
<code>
void
<strong>subscribe</strong>
(
fn
,
obj
,
override
)
</code>
<div class="description">
Subscribes the caller to this event
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>fn &lt;Function&gt;</code>
The function to execute
</dd>
<dd>
<code>obj &lt;Object&gt;</code>
An object to be passed along when the event
fires
</dd>
<dd>
<code>override &lt;boolean|Object&gt;</code>
If true, the obj passed in becomes
the execution scope of the listener.
if an object, that object becomes the
the execution scope.
</dd>
</dl>
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_toString">toString</a></h4>
<div class="detail">
<code>
void
<strong>toString</strong>
(
)
</code>
<div class="description">
</div>
<div class="description">
<dl>
<dt>Returns:
<code>
void
</code></dt>
<dd></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_unsubscribe">unsubscribe</a></h4>
<div class="detail">
<code>
boolean
<strong>unsubscribe</strong>
(
fn
,
obj
)
</code>
<div class="description">
Unsubscribes subscribers.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>fn &lt;Function&gt;</code>
The subscribed function to remove, if not supplied
all will be removed
</dd>
<dd>
<code>obj &lt;Object&gt;</code>
The custom object passed to subscribe. This is
optional, but if supplied will be used to
disambiguate multiple listeners that are the same
(e.g., you subscribe many object using a function
that lives on the prototype)
</dd>
</dl>
<dl>
<dt>Returns:
<code>
boolean
</code></dt>
<dd>True if the subscriber was found and detached.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="">
<h4>
<a name="method_unsubscribeAll">unsubscribeAll</a></h4>
<div class="detail">
<code>
int
<strong>unsubscribeAll</strong>
(
)
</code>
<div class="description">
Removes all listeners
</div>
<div class="description">
<dl>
<dt>Returns:
<code>
int
</code></dt>
<dd>The number of listeners unsubscribed</dd>
</dl>
</div>
</div>
<hr />
</div>
</div>
</div>
<div class="section method details">
<h3 id="events">Events</h3>
<div class="content">
<div class="">
<h4>
<a name="event_subscribeEvent">subscribeEvent</a></h4>
<div class="detail">
<code>
<strong>subscribeEvent</strong>
(
fn
,
obj
,
override
)
</code>
<div class="description">
Custom events provide a custom event that fires whenever there is
a new subscriber to the event. This provides an opportunity to
handle the case where there is a non-repeating event that has
already fired has a new subscriber.
</div>
<div class="description">
<dl>
<dt>Parameters:</dt>
<dd>
<code>fn &lt;Function&gt;</code>
The function to execute
</dd>
<dd>
<code>obj &lt;Object&gt;</code>
An object to be passed along when the event
fires
</dd>
<dd>
<code>override &lt;boolean|Object&gt;</code>
If true, the obj passed in becomes
the execution scope of the listener.
if an object, that object becomes the
the execution scope.
</dd>
</dl>
</div>
</div>
<hr />
</div>
</div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_animation.html">animation</a></li>
<li class=""><a href="module_autocomplete.html">autocomplete</a></li>
<li class=""><a href="module_button.html">button</a></li>
<li class=""><a href="module_calendar.html">calendar</a></li>
<li class=""><a href="module_carousel.html">carousel</a></li>
<li class=""><a href="module_charts.html">charts</a></li>
<li class=""><a href="module_colorpicker.html">colorpicker</a></li>
<li class=""><a href="module_connection.html">connection</a></li>
<li class=""><a href="module_container.html">container</a></li>
<li class=""><a href="module_cookie.html">cookie</a></li>
<li class=""><a href="module_datasource.html">datasource</a></li>
<li class=""><a href="module_datatable.html">datatable</a></li>
<li class=""><a href="module_dom.html">dom</a></li>
<li class=""><a href="module_dragdrop.html">dragdrop</a></li>
<li class=""><a href="module_editor.html">editor</a></li>
<li class=""><a href="module_element.html">element</a></li>
<li class="selected"><a href="module_event.html">event</a></li>
<li class=""><a href="module_get.html">get</a></li>
<li class=""><a href="module_history.html">history</a></li>
<li class=""><a href="module_imagecropper.html">imagecropper</a></li>
<li class=""><a href="module_imageloader.html">imageloader</a></li>
<li class=""><a href="module_json.html">json</a></li>
<li class=""><a href="module_layout.html">layout</a></li>
<li class=""><a href="module_logger.html">logger</a></li>
<li class=""><a href="module_menu.html">menu</a></li>
<li class=""><a href="module_paginator.html">paginator</a></li>
<li class=""><a href="module_profiler.html">profiler</a></li>
<li class=""><a href="module_profilerviewer.html">profilerviewer</a></li>
<li class=""><a href="module_resize.html">resize</a></li>
<li class=""><a href="module_selector.html">selector</a></li>
<li class=""><a href="module_slider.html">slider</a></li>
<li class=""><a href="module_tabview.html">tabview</a></li>
<li class=""><a href="module_treeview.html">treeview</a></li>
<li class=""><a href="module_uploader.html">uploader</a></li>
<li class=""><a href="module_yahoo.html">yahoo</a></li>
<li class=""><a href="module_yuiloader.html">yuiloader</a></li>
<li class=""><a href="module_yuitest.html">yuitest</a></li>
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
<li class="selected"><a href="YAHOO.util.CustomEvent.html">YAHOO.util.CustomEvent</a></li>
<li class=""><a href="YAHOO.util.Event.html">YAHOO.util.Event</a></li>
<li class=""><a href="YAHOO.util.EventProvider.html">YAHOO.util.EventProvider</a></li>
<li class=""><a href="YAHOO.util.KeyListener.html">YAHOO.util.KeyListener</a></li>
<li class=""><a href="YAHOO.util.Subscriber.html">YAHOO.util.Subscriber</a></li>
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="CustomEvent.js.html">CustomEvent.js</a></li>
<li class=""><a href="Event.js.html">Event.js</a></li>
<li class=""><a href="EventProvider.js.html">EventProvider.js</a></li>
<li class=""><a href="KeyListener.js.html">KeyListener.js</a></li>
</ul>
</div>
<div class="module">
<h4>Properties</h4>
<ul class="content">
<li class=""><a href="#property_lastError">lastError</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_scope">scope</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_signature">signature</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_silent">silent</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_subscribers">subscribers</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_type">type</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_YAHOO.util.CustomEvent.FLAT">YAHOO.util.CustomEvent.FLAT</a>
<!--<code>&lt;int&gt;</code>-->
</li>
<li class=""><a href="#property_YAHOO.util.CustomEvent.LIST">YAHOO.util.CustomEvent.LIST</a>
<!--<code>&lt;int&gt;</code>-->
</li>
</ul>
</div>
<div class="module">
<h4>Methods</h4>
<ul class="content">
<li class="private"><!--<code>void</code>-->
<a href="#method__delete">_delete</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_fire">fire</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_subscribe">subscribe</a>
</li>
<li class=""><!--<code>void</code>-->
<a href="#method_toString">toString</a>
</li>
<li class=""><!--<code>boolean</code>-->
<a href="#method_unsubscribe">unsubscribe</a>
</li>
<li class=""><!--<code>int</code>-->
<a href="#method_unsubscribeAll">unsubscribeAll</a>
</li>
</ul>
</div>
<div class="module">
<h4>Events</h4>
<ul class="content">
<li class="">
<a href="#event_subscribeEvent">subscribeEvent</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>