Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ miniwindow initialized earlier than the main window

miniwindow initialized earlier than the main window

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zhenzh   China  (68 posts)  Bio
Date Wed 20 Jun 2018 02:43 PM (UTC)
Message
I have a miniwindow plugin enabled in my script. It will be loaded each time starting a .MCL script.

The window position is calcuated from the size of main window.

My problem is that the miniwindow can not be located in the specified position.

I find the root cause of the issue is that the main window has not been ready when installing the miniwindow plugin which passed an incorrect window size to the plugin.

I added some debug messages in my plugin install function to proved my guess:


function OnPluginInstall ()
    
    Note(GetInfo(281))  -- get windows width
    DoAfterSepcial(5, "Note(GetInfo(281))", sendto.script)  -- get windows width again after 5 secs

end


I got the first valuse 791 and the second value 1419, which shows when plugin is installed, the main window has not been completely initialized.

How can I force the plugin install staring after main window is ready?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 21 Jun 2018 06:40 AM (UTC)
Message
"DoAfterSepcial" looks like a typo.

You can use DoAfterSpecial to initialize the miniwindow after a couple of seconds (rather than in OnPluginInstall).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zhenzh   China  (68 posts)  Bio
Date Reply #2 on Sat 23 Jun 2018 12:06 AM (UTC)
Message
How to get the plugin installed out of OnPluginInstall ?

I tried add DoAfterSpecial within OnPluginInstall function but it doesn't work as some parameters can not be passed.


function OnPluginInstall ()
    
    DoAfterSpecial(5, "tabbed_window.init (context1)", sendto.script)
    DoAfterSpecial(5, "tabbed_window.draw_window (context1, 1)", sendto.script)

end


Quote:

Reason: Executing plugin tabbed_window sub OnPluginInstall
C:\MUSHClient\lua\tabbed_window.lua:240: attempt to perform arithmetic on field 'height' (a nil value)
stack traceback:
C:\MUSHClient\lua\tabbed_window.lua:240: in function 'draw_window'
[string "Plugin: tabbed_window"]:630: in function <[string "Plugin: tabbed_window"]:624>
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 23 Jun 2018 03:00 AM (UTC)
Message
Just call a function (eg. DelayedInstall) and then have that do all the work.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zhenzh   China  (68 posts)  Bio
Date Reply #4 on Sat 23 Jun 2018 01:47 PM (UTC)
Message
Finially, I get the plugin works by auto-detecting the status of the main window.


function OnPluginInstall ()
    wait.make(function()
        repeat
            if GetInfo(285) == true then
                InstallAfterReady()
                break
            end
            wait.time(0.5)
        until false
    end)
end

function InstallAfterReady()
    context1.window.left = GetInfo(281) - 600
    tabbed_window.init (context1)
    tabbed_window.draw_window (context1, 1)
end
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,650 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.