4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-button-Split'>/**
19 </span> * A split button that provides a built-in dropdown arrow that can fire an event separately from the default click event
20 * of the button. Typically this would be used to display a dropdown menu that provides additional options to the
21 * primary button action, but any custom handler can provide the arrowclick implementation. Example usage:
24 * // display a dropdown menu:
25 * Ext.create('Ext.button.Split', {
26 * renderTo: Ext.getBody(),
28 * // handle a click on the button itself
29 * handler: function() {
30 * alert("The button was clicked");
32 * menu: new Ext.menu.Menu({
34 * // these will render as dropdown menu items when the arrow is clicked:
35 * {text: 'Item 1', handler: function(){ alert("Item 1 clicked"); }},
36 * {text: 'Item 2', handler: function(){ alert("Item 2 clicked"); }}
41 * Instead of showing a menu, you can provide any type of custom functionality you want when the dropdown
44 * Ext.create('Ext.button.Split', {
45 * renderTo: 'button-ct',
47 * handler: optionsHandler,
48 * arrowHandler: myCustomHandler
52 Ext.define('Ext.button.Split', {
54 /* Begin Definitions */
55 alias: 'widget.splitbutton',
57 extend: 'Ext.button.Button',
58 alternateClassName: 'Ext.SplitButton',
61 <span id='Ext-button-Split-cfg-arrowHandler'> /**
62 </span> * @cfg {Function} arrowHandler
63 * A function called when the arrow button is clicked (can be used instead of click event)
65 <span id='Ext-button-Split-cfg-arrowTooltip'> /**
66 </span> * @cfg {String} arrowTooltip
67 * The title attribute of the arrow
75 initComponent : function(){
77 <span id='Ext-button-Split-event-arrowclick'> /**
78 </span> * @event arrowclick
79 * Fires when this button's arrow is clicked.
80 * @param {Ext.button.Split} this
81 * @param {Event} e The click event
83 this.addEvents("arrowclick");
86 <span id='Ext-button-Split-method-setArrowHandler'> /**
87 </span> * Sets this button's arrow click handler.
88 * @param {Function} handler The function to call when the arrow is clicked
89 * @param {Object} scope (optional) Scope for the function passed above
91 setArrowHandler : function(handler, scope){
92 this.arrowHandler = handler;
97 onClick : function(e, t) {
102 if (me.overMenuTrigger) {
104 me.fireEvent("arrowclick", me, e);
105 if (me.arrowHandler) {
106 me.arrowHandler.call(me.scope || me, me, e);