我在写分页中组合键的跳页问题在网站中看到这样的用法:
ExtJS中处理键盘事件很简单,在配置属性中加一个keys:object即可,
object结构如下:
key String/Array 进行处理的单个keycode或keycodes组成的数组
shift Boolean True:只有shift按下的的同时处理key (默认false)
ctrl Boolean True:只有ctrl按下的的同时处理key (默认false)
handler Function 当KeyMap找到预期的组合键时所执行的函数
alt Boolean True:只有alt按下的的同时处理key (默认false)
fn Function 当组合键按下后回调函数
scope Object 回调函数的作用域
然后试了下为什么没有用?
me.pagingToolbar = Ext.create('Ext.toolbar.Paging', {
dock: 'bottom',
displayInfo: true,
bind: me.config.bind,
keys: [
{
key: [37, 39],
alt: true,
fn: function (e) {
var thisPagingToolbar = me.pagingToolbar;
me.PagingToolbar_KeyEvent(thisPagingToolbar, e);
}
}],
me.dockedItems.push(me.pagingToolbar);
},
这是 me.PagingToolbar_KeyEvent= function (thisPagingToolbar, e) {
if ((e.getKey() == Ext.event.Event.LEFT) || (e.getKey() == Ext.event.Event.PAGE_UP)) {
if (thisPagingToolbar.getPageData().currentPage!= 1)
thisPagingToolbar.movePrevious();
}
if ((e.getKey() == Ext.event.Event.RIGHT) || (e.getKey() == Ext.event.Event.PAGE_DOWN)) {
if (thisPagingToolbar.getPageData().currentPage != thisPagingToolbar.getPageData().pageCount)
thisPagingToolbar.moveNext();
}
if (e.getKey() == Ext.event.Event.HOME) {
if (thisPagingToolbar.getPageData().currentPage!= 1)
thisPagingToolbar.moveFirst();
}
if (e.getKey() == Ext.event.Event.END) {
if (thisPagingToolbar.getPageData().currentPage != thisPagingToolbar.getPageData().pageCount)
thisPagingToolbar.moveLast();
}
}方法,求大神指教