3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * A split button that provides a built-in dropdown arrow that can fire an event separately from the default click event
17 * of the button. Typically this would be used to display a dropdown menu that provides additional options to the
18 * primary button action, but any custom handler can provide the arrowclick implementation. Example usage:
21 * // display a dropdown menu:
22 * Ext.create('Ext.button.Split', {
23 * renderTo: Ext.getBody(),
25 * // handle a click on the button itself
26 * handler: function() {
27 * alert("The button was clicked");
29 * menu: new Ext.menu.Menu({
31 * // these will render as dropdown menu items when the arrow is clicked:
32 * {text: 'Item 1', handler: function(){ alert("Item 1 clicked"); }},
33 * {text: 'Item 2', handler: function(){ alert("Item 2 clicked"); }}
38 * Instead of showing a menu, you can provide any type of custom functionality you want when the dropdown
41 * Ext.create('Ext.button.Split', {
42 * renderTo: 'button-ct',
44 * handler: optionsHandler,
45 * arrowHandler: myCustomHandler
49 Ext.define('Ext.button.Split', {
51 /* Begin Definitions */
52 alias: 'widget.splitbutton',
54 extend: 'Ext.button.Button',
55 alternateClassName: 'Ext.SplitButton',
59 * @cfg {Function} arrowHandler
60 * A function called when the arrow button is clicked (can be used instead of click event)
63 * @cfg {String} arrowTooltip
64 * The title attribute of the arrow
72 initComponent : function(){
76 * Fires when this button's arrow is clicked.
77 * @param {Ext.button.Split} this
78 * @param {Event} e The click event
80 this.addEvents("arrowclick");
84 * Sets this button's arrow click handler.
85 * @param {Function} handler The function to call when the arrow is clicked
86 * @param {Object} scope (optional) Scope for the function passed above
88 setArrowHandler : function(handler, scope){
89 this.arrowHandler = handler;
94 onClick : function(e, t) {
99 if (me.overMenuTrigger) {
101 me.fireEvent("arrowclick", me, e);
102 if (me.arrowHandler) {
103 me.arrowHandler.call(me.scope || me, me, e);