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 ➜ General ➜ Closing a World Window?

Closing a World Window?

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


Posted by Bludhound   (2 posts)  Bio
Date Mon 23 Feb 2009 04:44 PM (UTC)
Message
Hi, I have been searching for a function to close a world window, but to no avail. Basically, I would like the world window to close automatically upon disconnection. There doesn't seem to be an option for this, so I'm trying to write my own callback function to do this. Are there any better solutions to this? Thanks in advance!
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Mon 23 Feb 2009 04:55 PM (UTC)

Amended on Mon 23 Feb 2009 05:03 PM (UTC) by Worstje

Message
Try a plugin with:


function OnPluginDisconnect()
  DoCommand("Close")
end


I am not sure how this would play if you had multiple windows open though, given the fact it posts messages to the command queue rather than really uses the world object. (In other words - it might just close the active world rather than the one that just disconnected.)

Additionally, to avoid the popup asking you to save, you might want to turn that off in the global configuration.

Edit: I just tested, and my suspicion was correct. It closes the currently active window. A simple timer in world #1 and a bunch of other worlds open which had the focus would one by one close the other worlds until the first world ended up as the one with the focus. As such, this solution will end up shooting in your foot if you use more than one world/window.
Top

Posted by Bludhound   (2 posts)  Bio
Date Reply #2 on Mon 23 Feb 2009 05:00 PM (UTC)
Message
I guess it'll work if I can save the currently active world, make the disconnected world active, close it, then return to the inactive world. I'll give it a shot, thanks for the help!
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 23 Feb 2009 07:03 PM (UTC)
Message
Activate it and then close.

eg.


function OnPluginDisconnect()
  Activate ()
  DoCommand("Close")
end


Alternatively, type this into the box for "Disconnect" on the scripting page:


!/Activate();DoCommand ("close")



- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #4 on Mon 23 Feb 2009 07:49 PM (UTC)
Message
I totally overlooked Activate(). I looked for a Focus/Activate in DoCommand(), but yeah. ^^ Glad there's a solution after all, though!
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.


15,285 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.