Extjs实现快捷键CTRL+TAB对Tabpanel进行Tab切换

 

// 注册ctrl+tab组合键到keymap
var keyMap=new Ext.KeyMap(Ext.getBody(),[{  
			    	  key:[9], //tab
			    	  ctrl:true,
			    	  fn:function(){handleCtrlTab();}
			    	  scope:this,
			    	  defaultEventAction: "stopEvent"
			      }]
			);  
keyMap.enable();

// 实现tabpanel的切换
function handleCtrlTab()
{
	var targetTabPanel = Ext.getCmp('mytabpanel');
	var curTab = targetTabPanel.getActiveTab();
	var curIndex = targetTabPanel.items.indexOf(curTab);
	var nextTabIndex = curIndex + 1;
	var itemSize = targetTabPanel.items.length;
	if (nextTabIndex >= itemSize)
	{
		nextTabIndex = 0;
	}
	
	var nextTab = targetTabPanel.items.itemAt(nextTabIndex);
	targetTabPanel.activate(nextTab);
	
	// 10ms进行聚焦,保证连续响应ctrl+tab
	nextTab.focus(false, 10);  
}
 

你可能感兴趣的:(tab,ExtJs,tabpanel,切换)