在 Ext JS 中捕获网格行的长按或点按事件

Capture long press or tap hold event of grid row in Ext JS

我正在使用网格的 rowcontextmenu 事件在右键单击时显示一些选项,这在桌面上运行良好。在 iPad 中,我想在长按时实现相同的功能,但我在 sencha 文档中发现了任何此类事件。我试过 jquery 长按插件但是无法实现。 我正在使用 Ext JS 3.4 版本。请任何提示。

这些监听器(至少)必须应用于 "Handling Events" 的 Ext.grid.RowSelectionModel, so that these events are being properly bound within that particular scope. see this blog article; there are a bunch more DOM event types to consider. the event you are looking for is either called taphold or longpress (see the Safari 文档。

RowSelectionModel 的事件可以这样定义:

new Ext.grid.GridPanel({

    /**
     * one has to instance the default row-selection model explicitly,
     * in order to be able to configure it's event listeners ...
    **/
    sm: new Ext.grid.RowSelectionModel({
        singleSelect: true,
        listeners: {

            taphold: 'rowcontextmenu'

        }
    })

});

也可以使用Ext.util.Observable调试事件;这很方便,特别是在使用过时的框架时,在功能已经支持到什么程度方面相当值得怀疑。

// to intercept all events:
Ext.util.Observable.prototype.fireEvent = 
Ext.util.Observable.prototype.fireEvent.createInterceptor(function() {
    console.log(this.name);
    console.log(arguments);
    return true;
});

// to capture the events of a particular component:
Ext.util.Observable.capture(
    Ext.getCmp('my-grid-component'), function(event) {
        console.info(event);
    }
);

使用 Ext.EventManager.addListener() or .on(),可以定义任何缺少的框架事件。