Sencha列表用键盘滚动 [英] Sencha list scrolling with keyboard
本文介绍了Sencha列表用键盘滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我。
这是我的代码:
{
xtype:'list',
pinHeaders:false,
variableHeights:false,
itemTpl:
'< div>'+
'< div> {name}< / div>'+
'< / div>',
存储:'myStore',
分组:true,
onItemDisclosure:true
}
解决方案
查看这个小提琴 https:// fiddle .sencha.com /#fiddle / 53t
您可以在应用程序启动功能中的keydown事件中添加文档事件监听器,然后按照您的列表项。
Ext.application({
name:'Fiddle',
launch:function(){
Ext.Viewport.add({
xtype:'slidelist'
});
document.addEventListener(keydown,Ext.bind(onBackKeyDown,this),false);
function onBackKeyDown(e){
switch(e.keyIdentifier)
{
caseUp:
Ext.ComponentQuery.query('slidelist')[0 ] .getScrollable()。getScroller()。scrollBy(0,-47);
break;
caseDown:
Ext.ComponentQuery.query('slidelist')[0] .getScrollable()。getScroller()。scrollBy(0,47);
break;
默认值:
break;
}
}
}
});
I am using sencha list in my application. It is a scrollable list. I want to scroll the list by up, down key and hand gesture in keyboard. Does anyone know how to do it?
Please help me.
This is my code:
{
xtype: 'list',
pinHeaders: false,
variableHeights: false,
itemTpl:
'<div>' +
'<div>{name}</div>' +
'</div>',
store: 'myStore',
grouped: true,
onItemDisclosure: true
}
解决方案
Check out this fiddle https://fiddle.sencha.com/#fiddle/53t
You can add a document eventlistener on keydown event in your application launch function and then scroll by the height of your list item.
Ext.application({
name: 'Fiddle',
launch: function() {
Ext.Viewport.add({
xtype: 'slidelist'
});
document.addEventListener("keydown", Ext.bind(onBackKeyDown, this), false);
function onBackKeyDown(e) {
switch(e.keyIdentifier)
{
case "Up":
Ext.ComponentQuery.query('slidelist')[0].getScrollable().getScroller().scrollBy(0, -47);
break;
case "Down":
Ext.ComponentQuery.query('slidelist')[0].getScrollable().getScroller().scrollBy(0, 47);
break;
default:
break;
}
}
}
});
这篇关于Sencha列表用键盘滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文