Sencha list scrolling with keyboard

无人久伴 提交于 2019-12-04 14:16:57

问题


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
}

回答1:


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;
            }
        }
    }
});


来源:https://stackoverflow.com/questions/21154398/sencha-list-scrolling-with-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!