[英]How can I detect when the context menu has been hidden?
I'm developing an extension for Google Chrome using JQuery and Javascript and I want to set a variable to "true" when the user open the context menu and set the variable to "false" when the context menu is hidden. 我正在开发使用JQuery和Javascript的Google Chrome扩展程序,我想在用户打开上下文菜单时将变量设置为“ true”,而在隐藏上下文菜单时将变量设置为“ false”。
I can detect when it's open with the following code: 我可以使用以下代码检测它何时打开:
var contextMenuOpen;
$(document).on("contextmenu", function(e){
contextMenuOpen = true;
});
But I don't know how can I detect if it is hidden. 但是我不知道如何检测它是否被隐藏。
Thanks in advance and sorry for my English. 在此先感谢您,我的英语很抱歉。
in the context menu definition you can implement the hide event function 在上下文菜单定义中,您可以实现hide事件功能
events: {
hide: function(opt){
//.. do what you need
}
}
or i everywhere you need you could check if context menu div has the "context-menu-active" class 或者我到处都需要,您可以检查上下文菜单div是否具有“ context-menu-active”类
if ("#myDiv").hasClass("context-menu-active")) {
$("#myDiv").contextMenu("hide");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.