如何在ExtJs选项卡上实现accesskey? [英] How to implement accesskey on ExtJs tabs?

查看:99
本文介绍了如何在ExtJs选项卡上实现accesskey?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我们的产品中实现了可滚动的extjs选项卡。但是我也需要支持accesskey功能。例如,Alt + P按键将打开其中一个选项卡。有没有人有实现这个的任何经验?

I have implemented scrollable extjs tab panel in our product. But I also need to support accesskey functionality. For example, an "Alt + P" keystroke will open up one of tab. Does anyone have any experience about implementing this?

推荐答案

这个的核心是创建一个键盘映射,键,一旦检测到,您可以添加一个自定义处理程序。

The core to this is creating a keymap to recognise you are pressing a combination of keys, once this is detected you can then add a custom handler.

参见这里: http://dev.sencha.com/deploy/dev/docs/?class=Ext.KeyMap

例如:

var map = new Ext.KeyMap("my-element", [
    {
        key: [10,13],
        fn: function(){ alert("Return was pressed"); }
    }, {
        key: "abc",
        fn: function(){ alert('a, b or c was pressed'); }
    }, {
        key: "\t",
        ctrl:true,
        shift:true,
        fn: function(){ alert('Control + shift + tab was pressed.'); }
    }
]);

以上是一些示例映射,您只需将my-element替换为您希望的元素寻找按键(所选择的元素会检测到它们)。如果您希望具有APPLICATION宽键映射,则该元素应该是页面的主体,窗口本身或ExtJS视口(如果使用的话)/主元素。这意味着您可以在应用程序的任何区域内,并且检测到按键。您在fn属性下定义的后续行为(即更改选项卡等)...

Above are a number of sample mappings, you simply replace 'my-element' with the element you wish to look for the key presses on (so which element when selected will detect them). If you wish to have APPLICATION wide key mapping, this element should either be the body of the page, the window itself or the ExtJS Viewport (if you are using one) / Master element. This will mean you can be within any area of your application and the keypress is detected. The subsequent behaviour you define under the 'fn' property (i.e. change tab etc)...

这篇关于如何在ExtJs选项卡上实现accesskey?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆