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 * @class Ext.button.Split
17 * @extends Ext.button.Button
18 * A split button that provides a built-in dropdown arrow that can fire an event separately from the default
19 * click event of the button. Typically this would be used to display a dropdown menu that provides additional
20 * options to the primary button action, but any custom handler can provide the arrowclick implementation.
21 * {@img Ext.button.Split/Ext.button.Split.png Ext.button.Split component}
24 // display a dropdown menu:
25 Ext.create('Ext.button.Split', {
26 renderTo: 'button-ct', // the container id
28 handler: optionsHandler, // handle a click on the button itself
29 menu: new Ext.menu.Menu({
31 // these items will render as dropdown menu items when the arrow is clicked:
32 {text: 'Item 1', handler: item1Handler},
33 {text: 'Item 2', handler: item2Handler}
38 // Instead of showing a menu, you provide any type of custom
39 // functionality you want when the dropdown arrow is clicked:
40 Ext.create('Ext.button.Split', {
41 renderTo: 'button-ct',
43 handler: optionsHandler,
44 arrowHandler: myCustomHandler
47 * @cfg {Function} arrowHandler A function called when the arrow button is clicked (can be used instead of click event)
48 * @cfg {String} arrowTooltip The title attribute of the arrow
50 Ext.define('Ext.button.Split', {
52 /* Begin Definitions */
54 alias: 'widget.splitbutton',
56 extend: 'Ext.button.Button',
57 alternateClassName: 'Ext.SplitButton',
64 initComponent : function(){
68 * Fires when this button's arrow is clicked
69 * @param {MenuButton} this
70 * @param {EventObject} e The click event
72 this.addEvents("arrowclick");
76 * Sets this button's arrow click handler.
77 * @param {Function} handler The function to call when the arrow is clicked
78 * @param {Object} scope (optional) Scope for the function passed above
80 setArrowHandler : function(handler, scope){
81 this.arrowHandler = handler;
86 onClick : function(e, t) {
91 if (me.overMenuTrigger) {
92 if (me.menu && !me.menu.isVisible() && !me.ignoreNextClick) {
95 me.fireEvent("arrowclick", me, e);
96 if (me.arrowHandler) {
97 me.arrowHandler.call(me.scope || me, me, e);
100 if (me.enableToggle) {
103 me.fireEvent("click", me, e);
105 me.handler.call(me.scope || me, me, e);