表中的输入字段中循环时

表中的输入字段中循环时

本文介绍了在 SAPUI5 表中的输入字段中循环时,有没有办法避免按住 ALT 键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含输入字段的 SAPUI5 表.我在 http://jsfiddle.net/bgerth/x8h92mz8/ 准备了一个例子.

I have a SAPUI5 table which contains input fields. I have prepared an example at http://jsfiddle.net/bgerth/x8h92mz8/.

当您按 ALT+TAB 时,您可以在表中的输入字段之间循环(我是通过查看 sap.m.ListBase.prototype._startItemNavigation).只有按 TAB 键才会聚焦表格外的第一个元素.

When you press ALT+TAB you can cycle through the input fields within the table (I only found that out by looking at sap.m.ListBase.prototype._startItemNavigation).Only pressing TAB focuses the first element outside the table.

我认为这很不直观.有没有办法让 TAB 单独以同样的方式工作?

I consider that rather non-intuitive. Is there a way to make TAB alone work the same way?

更新:

Alt+Tab 在 Chrome 和 Safari 中有效,但在 Mac 上的 Firefox (45.0.2) 中无效.它在 Windows 上根本不起作用,因为该组合保留用于在打开的应用程序窗口之间切换.

Alt+Tab works in Chrome and Safari, but not Firefox (45.0.2) on my Mac. It doesn't work at all on Windows, as that combination is reserved to toggle through open application windows.

推荐答案

目前我发现了两种解决方案来解决这个问题

There are two solutions I discovered so far to address this problem

我找到了博客 SAPUI5 Table Navigation with Tab Key 由 Klaus Kronawetter 为 sap.ui.table.Table 添加了额外的键盘处理.我为 sap.m.Table 修改了他的代码,你可以在 http://jsfiddle.net/bgerth/os6r096y.

I have found the blog SAPUI5 Table Navigation with Tab Key by Klaus Kronawetter which adds extra keyboard handling to a sap.ui.table.Table. I adapted his code for a sap.m.Table which you can find at http://jsfiddle.net/bgerth/os6r096y.

不幸的是,代码相当长.

Unfortunately, the code is rather lenghty.

经过进一步调查,我认为上述建议 1 的解决方案太麻烦了.

After further investigation, I decided that the solution from proposal 1 above is too much hassle.

相反,我改编了上面提到的 sap.ui.core.delegate.ItemNavigation 类,该类在 sap.m.ListBase 内部使用.本质上,您可以使用向上和向下箭头键在输入字段之间循环.

Instead, I adapted the class sap.ui.core.delegate.ItemNavigationmentioned above, which is internally employed by sap.m.ListBase. In essence, you can cycle through the input fields with up and down arrow keys.

我在 http://jsfiddle.net/bgerth/0r9L30wd 准备了一个示例.相关代码是

I have prepared an example at http://jsfiddle.net/bgerth/0r9L30wd. The relevant code is

var fnPatchedItemNavigationsetItemDomRefs = sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs;
sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs = function setItemDomRefsPatched(aItemDomRefs) {
    // 'this' is now the instance of sap.ui.core.delegate.ItemNavigation
    jQuery.sap.log.debug("Patched version of sap.ui.core.delegate.ItemNavigation.setItemDomRefs");
    var aInputFields = $(aItemDomRefs).find("input:enabled").get();
    if (aInputFields[0]) {
        // There is at least one enabled input field in this table
        return fnPatchedItemNavigationsetItemDomRefs.call(this, aInputFields);
    } else {
        return fnPatchedItemNavigationsetItemDomRefs.call(this, aItemDomRefs);
    }
}

这篇关于在 SAPUI5 表中的输入字段中循环时,有没有办法避免按住 ALT 键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 04:11