简体   繁体   English

如何从选项卡顺序中删除必应地图(和所有子控件)

[英]How to remove Bing map (and all child controls) from tab order

Does the Bing maps control (Microsoft.Maps.Map) offer an API for removing itself (and its child controls) from the tab order? 必应地图控件(Microsoft.Maps.Map)是否提供用于从选项卡顺序中删除自身(及其子控件)的API?

Alternatively, is there an appropriate callback (post rendering) I can use to set the tabIndex recursively on all elements once the map has rendered itself? 另外,地图渲染后,是否可以使用适当的回调(后期渲染)在所有元素上递归设置tabIndex?

NB : I've seen there are options at construction time for specifying whether to render the map type selector/locate me button/zoom buttons. 注意 :我已经看到在构建时有一些选项,用于指定是否渲染地图类型选择器/定位我按钮/缩放按钮。 But lets assume we want to render those controls just remove them from the tab order. 但是假设我们要渲染这些控件,只需将它们从制表符顺序中删除即可。

I managed to achieve it using a MutationObserver: 我设法使用MutationObserver实现它:

var mapElem = document.getElementById("map");

let deferredClearTabIndexEvent: number | undefined;

if (mapElem !== null) {
    var config = { attributes: true, childList: true, subtree: true };
    var callback = () => {
        if (deferredClearTabIndexEvent === undefined) {
            deferredClearTabIndexEvent = window.setTimeout(() => {
                var elements = mapElem!.querySelectorAll("a, button, input, select, textarea, [tabindex]")
                for (var i=0; i<elements.length; i++) {
                    elements[i].setAttribute("tabIndex", "-1");
                }

                deferredClearTabIndexEvent = undefined;
            }, 0);
        }
    };

    var observer = new MutationObserver(callback);
    observer.observe(mapElem, config);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM