Trying to create toggleable windows

Post Reply
teker
Posts: 6
Joined: Tue Feb 21, 2017 7:49 pm

Trying to create toggleable windows

Post by teker »

I'm trying to figure out how to make UI windows that can be enabled/shown or disabled/hidden and change functionality on the fly. For example, an optional chat window. When the window is up, I'd like it to append the text to the chat window. When it's hidden or closed, I want the chat messages to remain in the main console. The main problem I am having is figuring out how to identify if a given window has been created and if it is visible or hidden. Is it possible to do that?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Trying to create toggleable windows

Post by Jor'Mox »

As far as I'm aware, you can't check the status of a window in the way you are describing, so the method you would need to use would be to create some sort of boolean variable that you toggle when you toggle the status of the window, and check that variable when needed.

teker
Posts: 6
Joined: Tue Feb 21, 2017 7:49 pm

Re: Trying to create toggleable windows

Post by teker »

I am keeping state internally but I can't find a way to keep my state synchronized - like identifying when the user manually closes the window.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Trying to create toggleable windows

Post by Jor'Mox »

Not possible, at least not that I know. There is no way to track when a user closes a userWindow, unless appending to a window that doesn't exist causes some sort of error (I don't use userWindows, I focus on miniConsoles, because they are much easier to work with). IF there is an error when you try to write to a closed window, you could use pcall to catch that error and work from there.

teker
Posts: 6
Joined: Tue Feb 21, 2017 7:49 pm

Re: Trying to create toggleable windows

Post by teker »

Can I determine if a miniConsole exists?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Trying to create toggleable windows

Post by Jor'Mox »

Miniconsoles can only be dealt with via code, so there is no ability for users to close them short of executing an arbitrary function call. So, no, you can’t check to see if they exist, but it should generally be only your code that has the power to open or close them, so you should be able to track that as it happens.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Trying to create toggleable windows

Post by SlySven »

Ah closeUserWindow (the Lua command) is functionally the same as the Lua command hideUserWindow(...) - I suppose someone could probably write some C++ in the TLuaInterpreter class code to detect whether a windows is visible or not after using lua commands showWindow(...)/hideWindow(...) or if the user has done it themselves by clicking on the hide button? Is that what you are looking for?

Post Reply