Windows 7 小工具弹出问题
我的弹出窗口遇到问题。我的小工具会发生什么情况,您双击一个组件,它将有一个相应的弹出窗口。但是,如果双击该组件或任何其他带有弹出窗口的可视组件,则弹出窗口文档将返回 null。我不知道为什么会这样,如果你让弹出窗口消失并重新打开它或打开一个新窗口,那就可以了。仅当弹出窗口已打开时才会发生这种情况。我正在寻找一些关于为什么会这样的想法。
双击代码:
Blah.prototype.ondblclick = function()
{
var me = this.parent;
if (System.Gadget.Flyout.show)
{
// flyout is already shown, make sure it shows our stuff
System.Gadget.Flyout.file = FLYOUT_FILE;
onFlyoutShow();
}
else
{
System.Gadget.Flyout.file = FLYOUT_FILE;
System.Gadget.Flyout.onShow = onFlyoutShow;
System.Gadget.Flyout.show = true;
}
System.Gadget.Flyout.onHide = onFlyoutHide;
function onFlyoutShow()
{
me.flyoutOpen = true;
me.updateFlyout();
}
function onFlyoutHide()
{
me.flyoutOpen = false;
}
};
执行代码:
Blah.prototype.updateFlyout = function ()
{
var flyoutDoc = System.Gadget.Flyout.document;
//flyoutDoc is null at this point
var info = flyoutDoc.getElementById("info");
info.innerHTML = "info: " + this.information;
//Error thrown: 'null' is null or not an object
}
I'm having troubles with my flyout. What happens with my gadget is you double click a component and it will have a corresponding flyout window. If you double click that or any other visual component with a flyout, though, the flyout document is returned as null. I have no idea why this is, and if you make the flyout go away and reopen it or a new one it's ok. It's only when a flyout is already opened this happens. I'm looking for some ideas on why this is.
Double click code:
Blah.prototype.ondblclick = function()
{
var me = this.parent;
if (System.Gadget.Flyout.show)
{
// flyout is already shown, make sure it shows our stuff
System.Gadget.Flyout.file = FLYOUT_FILE;
onFlyoutShow();
}
else
{
System.Gadget.Flyout.file = FLYOUT_FILE;
System.Gadget.Flyout.onShow = onFlyoutShow;
System.Gadget.Flyout.show = true;
}
System.Gadget.Flyout.onHide = onFlyoutHide;
function onFlyoutShow()
{
me.flyoutOpen = true;
me.updateFlyout();
}
function onFlyoutHide()
{
me.flyoutOpen = false;
}
};
Executed code:
Blah.prototype.updateFlyout = function ()
{
var flyoutDoc = System.Gadget.Flyout.document;
//flyoutDoc is null at this point
var info = flyoutDoc.getElementById("info");
info.innerHTML = "info: " + this.information;
//Error thrown: 'null' is null or not an object
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对为 Windows 7 编写小工具了解不多,但对我来说,这看起来很像一个计时问题。当弹出窗口已经存在时,您可以更改
file
属性,让它加载新文件。无需等待,您就可以调用onFlyoutShow
来尝试获取文档,但文档尚未加载。onShow
事件不会触发吗?可能没有,或者你不会有“如果”,但值得验证。onFlyoutShow
。从一个较长的计时器开始,比如 1000。然后缩短它,希望可以降到 0:setTimeout(onFlyoutShow, 0);
I don't know a lot about writing gadgets for windows 7, but to me it looks a lot like a timing issue. When the flyout is already there, you change the
file
property which tells it to load a new file. Without waiting you then callonFlyoutShow
which tries to get the document and the document isn't loaded yet.onShow
event fire when you set the file? Probably doesn't or you wouldn't have the if, but worth verifying.onFlyoutShow
in a timeout. Start with a long timer, like 1000. And then shorten it, hopefully you can get down to 0:setTimeout(onFlyoutShow, 0);