Jump to content

Correctly handling GUI visibility via F2


Recommended Posts

I am updating my mod Telemetria, and I've had an issue that I've never been able to solve. As per the wiki for the Key Bindings reference, the default F2 key globally toggles UI visibility (or whatever override key is chosen). I am able to correctly handle this notification, and toggle my own visibility successfully, plus the user can also hide my mod with any keypress of their choosing.

BUT, the problem is I can't find a way to recognize if the user has previously hidden all screen elements with the F2 key. Then my mod gets "out of sync" with the global visibility. The user can hide my mod again, but that requires another keypress.

I've done some research on this, but all I found is this topic from 2013: https://forum.kerbalspaceprogram.com/index.php?/topic/32449-f2-button-does-not-hide-my-monobehaviour-icon/ where a comment matches my problem:

On 6/16/2013 at 12:47 PM, TheUndeadFish said:

I've tried looking through all the stuff that KSP exposes but I have yet to find a specific event or property that signals when the GUI should or should not be displayed.

 

So my question -- what flag indicates that the user wants ALL screen elements hidden?

Thanks for any help / suggestions.

Link to comment
Share on other sites

Actually I think I just solved it myself: I can watch for the global Hide All key press, and can determine current state of visibility by checking if it's been called an even or odd number of times.

I'd prefer to check an official global system flag, but this kludge seems to work. Hopefully this helps somebody else someday.

Link to comment
Share on other sites

Yep, confirmed. onHideUI/onShowUI is the correct answer and performed exactly as advertised. +1 to @cakepie for the advice!

In hindsight, it seems pretty obvious, but in my defense I also just found this 2015 thread with the identical problem:

If the prolific @linuxgurugamer had the same question, with an answer supplied by freakin' @Thomas P., then I'm in good company. :)

Link to comment
Share on other sites

56 minutes ago, BadRocket said:

Yep, confirmed. onHideUI/onShowUI is the correct answer and performed exactly as advertised. +1 to @cakepie for the advice!

In hindsight, it seems pretty obvious, but in my defense I also just found this 2015 thread with the identical problem:

If the prolific @linuxgurugamer had the same question, with an answer supplied by freakin' @Thomas P., then I'm in good company. :)

And while I may not have gotten the same answer back then, @cakepie is totally correct

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...