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-cfg-arrowTooltip'><span id='Ext-button-Split-cfg-arrowHandler'><span id='Ext-button-Split'>/**
19 </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 Ext.define('Ext.button.Split', {
55 /* Begin Definitions */
57 alias: 'widget.splitbutton',
59 extend: 'Ext.button.Button',
60 alternateClassName: 'Ext.SplitButton',
67 initComponent : function(){
69 <span id='Ext-button-Split-event-arrowclick'> /**
70 </span> * @event arrowclick
71 * Fires when this button's arrow is clicked
72 * @param {MenuButton} this
73 * @param {EventObject} e The click event
75 this.addEvents("arrowclick");
78 <span id='Ext-button-Split-method-setArrowHandler'> /**
79 </span> * Sets this button's arrow click handler.
80 * @param {Function} handler The function to call when the arrow is clicked
81 * @param {Object} scope (optional) Scope for the function passed above
83 setArrowHandler : function(handler, scope){
84 this.arrowHandler = handler;
89 onClick : function(e, t) {
94 if (me.overMenuTrigger) {
95 if (me.menu && !me.menu.isVisible() && !me.ignoreNextClick) {
98 me.fireEvent("arrowclick", me, e);
99 if (me.arrowHandler) {
100 me.arrowHandler.call(me.scope || me, me, e);
103 if (me.enableToggle) {
106 me.fireEvent("click", me, e);
108 me.handler.call(me.scope || me, me, e);