4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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-method-constructor'><span id='Ext-button-Split-cfg-arrowTooltip'><span id='Ext-button-Split-cfg-arrowHandler'><span id='Ext-button-Split'>/**
19 </span></span></span></span> * @class Ext.button.Split
20 * @extends Ext.button.Button
21 * A split button that provides a built-in dropdown arrow that can fire an event separately from the default
22 * click event of the button. Typically this would be used to display a dropdown menu that provides additional
23 * options to the primary button action, but any custom handler can provide the arrowclick implementation.
24 * {@img Ext.button.Split/Ext.button.Split.png Ext.button.Split component}
26 * <pre><code>
27 // display a dropdown menu:
28 Ext.create('Ext.button.Split', {
29 renderTo: 'button-ct', // the container id
31 handler: optionsHandler, // handle a click on the button itself
32 menu: new Ext.menu.Menu({
34 // these items will render as dropdown menu items when the arrow is clicked:
35 {text: 'Item 1', handler: item1Handler},
36 {text: 'Item 2', handler: item2Handler}
41 // Instead of showing a menu, you provide any type of custom
42 // functionality you want when the dropdown arrow is clicked:
43 Ext.create('Ext.button.Split', {
44 renderTo: 'button-ct',
46 handler: optionsHandler,
47 arrowHandler: myCustomHandler
49 </code></pre>
50 * @cfg {Function} arrowHandler A function called when the arrow button is clicked (can be used instead of click event)
51 * @cfg {String} arrowTooltip The title attribute of the arrow
53 * Create a new menu button
54 * @param {Object} config The config object
58 Ext.define('Ext.button.Split', {
60 /* Begin Definitions */
62 alias: 'widget.splitbutton',
64 extend: 'Ext.button.Button',
65 alternateClassName: 'Ext.SplitButton',
72 initComponent : function(){
74 <span id='Ext-button-Split-event-arrowclick'> /**
75 </span> * @event arrowclick
76 * Fires when this button's arrow is clicked
77 * @param {MenuButton} this
78 * @param {EventObject} e The click event
80 this.addEvents("arrowclick");
83 <span id='Ext-button-Split-method-setArrowHandler'> /**
84 </span> * 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) {
100 if (me.menu && !me.menu.isVisible() && !me.ignoreNextClick) {
103 me.fireEvent("arrowclick", me, e);
104 if (me.arrowHandler) {
105 me.arrowHandler.call(me.scope || me, me, e);
108 if (me.enableToggle) {
111 me.fireEvent("click", me, e);
113 me.handler.call(me.scope || me, me, e);