REQUIRED INFORMATION

Ext version tested:
  • Ext 4.0.2a

Browser versions tested against:
  • FF6 (firebug 1.8.1 installed)

Description:
  • If you have an app with the new MVC pattern and listen to toolbar buttons in a toolbar with enableOverflow: true via the control method, the events don't fire if you click on the items of the overflow menu.

Steps to reproduce the problem:
  • run the test case

The result that was expected:
  • the click event listener should be called

The result that occurs instead:
  • listener isn't called if you click overflow menu items

Test Case:

app.js
Code:
Ext.Loader.setConfig({
	enabled: true
});

Ext.application({
	name: 'App',
	controllers: [
		'Main'
	]
});
app/controller/Main.js
Code:
Ext.define('App.controller.Main', {
	extend: 'Ext.app.Controller',
	onButtonClick: function() {
		console.info('click', arguments);
	},
	init: function() {
		this.control({
			'window toolbar button': {
				'click': this.onButtonClick
			},
			'window toolbar button menu menuitem': {
				'click': this.onButtonClick
			}
		});
	},
	onLaunch: function() {
		Ext.create('Ext.window.Window', {
			title: 'Test',
			html: 'Resize the window so that the toolbar overflow menu becomes active and click buttons.',
			width: 400,
			height: 200,
			resizable: true,
			tbar: Ext.create('Ext.toolbar.Toolbar', {
				enableOverflow: true,
				items: [{
					text: 'Toolbar Button No 1'
				},{
					text: 'Toolbar Button No 2'
				},{
					text: 'Toolbar Button No 3'
				}]
			})
		}).show();
	}
});


HELPFUL INFORMATION

Debugging already done:
  • Ext.toolbar.Toolbar getRefItems should return the overflow menu items as well

Possible fix:
Code:
Ext.toolbar.Toolbar.override({
	getRefItems: function(deep) {
		var result = this.callOverridden(arguments),
			h;
		if (this.enableOverflow) {
			h = this.layout.overflowHandler;
			if (h instanceof Ext.layout.container.boxOverflow.Menu && h.menuTrigger) {
				h = h.menuTrigger;
				result.push(h);
				if (deep && h.getRefItems) {
					result.push.apply(result, h.getRefItems(true));
				}
			}
		}
		return result;
	}
});
Additional CSS used:
  • only default ext-all.css

Operating System:
  • Win7 Enterprise x64 SP1