Windows 7 小工具弹出问题

发布于 2024-10-12 23:54:32 字数 1180 浏览 7 评论 0原文

我的弹出窗口遇到问题。我的小工具会发生什么情况,您双击一个组件,它将有一个相应的弹出窗口。但是,如果双击该组件或任何其他带有弹出窗口的可视组件,则弹出窗口文档将返回 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬色的秋千 2024-10-19 23:54:32

我对为 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 call onFlyoutShow which tries to get the document and the document isn't loaded yet.

  • My first thought is: Doesn't the onShow event fire when you set the file? Probably doesn't or you wouldn't have the if, but worth verifying.
  • If that doesn't work, calling 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文