1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><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'>/**
2 </span></span></span></span> * @class Ext.button.Split
3 * @extends Ext.button.Button
4 * A split button that provides a built-in dropdown arrow that can fire an event separately from the default
5 * click event of the button. Typically this would be used to display a dropdown menu that provides additional
6 * options to the primary button action, but any custom handler can provide the arrowclick implementation.
7 * {@img Ext.button.Split/Ext.button.Split.png Ext.button.Split component}
9 * <pre><code>
10 // display a dropdown menu:
11 Ext.create('Ext.button.Split', {
12 renderTo: 'button-ct', // the container id
14 handler: optionsHandler, // handle a click on the button itself
15 menu: new Ext.menu.Menu({
17 // these items will render as dropdown menu items when the arrow is clicked:
18 {text: 'Item 1', handler: item1Handler},
19 {text: 'Item 2', handler: item2Handler}
24 // Instead of showing a menu, you provide any type of custom
25 // functionality you want when the dropdown arrow is clicked:
26 Ext.create('Ext.button.Split', {
27 renderTo: 'button-ct',
29 handler: optionsHandler,
30 arrowHandler: myCustomHandler
32 </code></pre>
33 * @cfg {Function} arrowHandler A function called when the arrow button is clicked (can be used instead of click event)
34 * @cfg {String} arrowTooltip The title attribute of the arrow
36 * Create a new menu button
37 * @param {Object} config The config object
41 Ext.define('Ext.button.Split', {
43 /* Begin Definitions */
45 alias: 'widget.splitbutton',
47 extend: 'Ext.button.Button',
48 alternateClassName: 'Ext.SplitButton',
55 initComponent : function(){
57 <span id='Ext-button.Split-event-arrowclick'> /**
58 </span> * @event arrowclick
59 * Fires when this button's arrow is clicked
60 * @param {MenuButton} this
61 * @param {EventObject} e The click event
63 this.addEvents("arrowclick");
66 <span id='Ext-button.Split-method-setArrowHandler'> /**
67 </span> * Sets this button's arrow click handler.
68 * @param {Function} handler The function to call when the arrow is clicked
69 * @param {Object} scope (optional) Scope for the function passed above
71 setArrowHandler : function(handler, scope){
72 this.arrowHandler = handler;
77 onClick : function(e, t) {
82 if (me.overMenuTrigger) {
83 if (me.menu && !me.menu.isVisible() && !me.ignoreNextClick) {
86 me.fireEvent("arrowclick", me, e);
87 if (me.arrowHandler) {
88 me.arrowHandler.call(me.scope || me, me, e);
91 if (me.enableToggle) {
94 me.fireEvent("click", me, e);
96 me.handler.call(me.scope || me, me, e);
102 });</pre></pre></body></html>