gpt4 book ai didi

Dojo:如何查找小部件是否在 dojo 中具有焦点

转载 作者:行者123 更新时间:2023-12-02 17:44:35 25 4
gpt4 key购买 nike

如何确定我的自定义小部件是否在 Dojo 中具有焦点

我有 dojo 编辑器,我想知道编辑器是否已经获得焦点?

最佳答案

你可以使用模块 dijit/focus 来找出焦点

来自 DOJO 文档

Tracking active widgets

At any point in time there is a set of (for lack of a better word) “active” or “focused” widgets, meaning the currently focused widget and that widget’s ancestors. “Ancestor” can mean either DOM ancestor (ex: TextBox –> Form), or a logical parent-child relationship (ex: TooltipDialog –> DropDownButton).

For example, if focus is on a TextBox inside a TabContainer inside a TooltipDialog triggered by a DropDownButton, the stack would be TextBox –> ContentPane –> TabContainer –> TooltipDialog –> DropDownButton.

The activeStack[] parameter indicates this set of widgets, and an app can monitor changes to activeStack[] by:

require([ "dijit/focus" ], function(focusUtil){
focusUtil.watch("activeStack", function(name, oldValue, newValue){
console.log("Focused widget + ancestors: ", newValue.join(", "));
});
});

关于Dojo:如何查找小部件是否在 dojo 中具有焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16623280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com