Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / Split.html
diff --git a/docs/source/Split.html b/docs/source/Split.html
new file mode 100644 (file)
index 0000000..9b9b1fe
--- /dev/null
@@ -0,0 +1,102 @@
+<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-button.Split-method-constructor'><span id='Ext-button.Split-cfg-arrowTooltip'><span id='Ext-button.Split-cfg-arrowHandler'><span id='Ext-button.Split'>/**
+</span></span></span></span> * @class Ext.button.Split
+ * @extends Ext.button.Button
+ * A split button that provides a built-in dropdown arrow that can fire an event separately from the default
+ * click event of the button.  Typically this would be used to display a dropdown menu that provides additional
+ * options to the primary button action, but any custom handler can provide the arrowclick implementation.  
+ * {@img Ext.button.Split/Ext.button.Split.png Ext.button.Split component}
+ * Example usage:
+ * &lt;pre&gt;&lt;code&gt;
+// display a dropdown menu:
+    Ext.create('Ext.button.Split', {
+        renderTo: 'button-ct', // the container id
+        text: 'Options',
+        handler: optionsHandler, // handle a click on the button itself
+        menu: new Ext.menu.Menu({
+        items: [
+                // these items will render as dropdown menu items when the arrow is clicked:
+                {text: 'Item 1', handler: item1Handler},
+                {text: 'Item 2', handler: item2Handler}
+        ]
+        })
+    });
+
+// Instead of showing a menu, you provide any type of custom
+// functionality you want when the dropdown arrow is clicked:
+    Ext.create('Ext.button.Split', {
+        renderTo: 'button-ct',
+        text: 'Options',
+        handler: optionsHandler,
+        arrowHandler: myCustomHandler
+    });
+&lt;/code&gt;&lt;/pre&gt;
+ * @cfg {Function} arrowHandler A function called when the arrow button is clicked (can be used instead of click event)
+ * @cfg {String} arrowTooltip The title attribute of the arrow
+ * @constructor
+ * Create a new menu button
+ * @param {Object} config The config object
+ * @xtype splitbutton
+ */
+
+Ext.define('Ext.button.Split', {
+
+    /* Begin Definitions */
+
+    alias: 'widget.splitbutton',
+
+    extend: 'Ext.button.Button',
+    alternateClassName: 'Ext.SplitButton',
+
+    // private
+    arrowCls      : 'split',
+    split         : true,
+
+    // private
+    initComponent : function(){
+        this.callParent();
+<span id='Ext-button.Split-event-arrowclick'>        /**
+</span>         * @event arrowclick
+         * Fires when this button's arrow is clicked
+         * @param {MenuButton} this
+         * @param {EventObject} e The click event
+         */
+        this.addEvents(&quot;arrowclick&quot;);
+    },
+
+<span id='Ext-button.Split-method-setArrowHandler'>     /**
+</span>     * Sets this button's arrow click handler.
+     * @param {Function} handler The function to call when the arrow is clicked
+     * @param {Object} scope (optional) Scope for the function passed above
+     */
+    setArrowHandler : function(handler, scope){
+        this.arrowHandler = handler;
+        this.scope = scope;
+    },
+
+    // private
+    onClick : function(e, t) {
+        var me = this;
+        
+        e.preventDefault();
+        if (!me.disabled) {
+            if (me.overMenuTrigger) {
+                if (me.menu &amp;&amp; !me.menu.isVisible() &amp;&amp; !me.ignoreNextClick) {
+                    me.showMenu();
+                }
+                me.fireEvent(&quot;arrowclick&quot;, me, e);
+                if (me.arrowHandler) {
+                    me.arrowHandler.call(me.scope || me, me, e);
+                }
+            } else {
+                if (me.enableToggle) {
+                    me.toggle();
+                }
+                me.fireEvent(&quot;click&quot;, me, e);
+                if (me.handler) {
+                    me.handler.call(me.scope || me, me, e);
+                }
+                me.onBlur();
+            }
+        }
+    }
+});</pre></pre></body></html>
\ No newline at end of file