Querying TextChatService chat window space usage

I want to have some UI respond dynamically to the size of the chat window, including in the scenario where the chat window has been completely closed by the player.

Apparently this can be accomplished by checking the AbsoluePosition and AbsoluteSize of the ChatWindowConfiguration and ChatInputBarConfiguration objects, but I don’t know the correct way to combine these values to get a fully accurate result (see Improve clarity around how to get total size of the chat window - simply adding all values as mentioned in the linked topic does not work).

It looks like we don’t have access to enough information determine the real size of the chat window. In the following screenshot, horizontal lines represent the Y values we have knowledge of - crucially, we are missing a line right at the bottom of the semi-transparent background frame:

The documentation says (Customizing In-Experience Text Chat | Documentation - Roblox Creator Hub):

By default, when enabling both the chat window and the chat bar, the chat bar attaches to the chat window on the UI. You can obtain their read-only properties on their positions and sizes and use them to calculate the total size of the combination:

but this isn’t really correct. So, at the moment I just have to pick random values for the padding between the chat input bar and the real bottom of the background frame and hope they work. In this case, I ended up with the following calculation: InputBarConfig.AbsolutePosition.Y + InputBarConfig.AbsoluteSize.Y + 8

This method of querying the chat size is also incorrect before the chat has been opened for the first time. In my opinion there should be an API to query these measurements which will always give the correct result always regardless of whether the chat is open or not, whether it has been opened before, etc.

Also the ChatInputBarConfiguration’s AbsoluteSize.Y value is reset to 35 when the chat is closed. Which seems like a bug – or at least undesirable behavior – as it causes unnecessary UI jittering if that value is being used by somebody else.

EDIT: This request originally mentioned trying to check whether the chat is open/closed, but it turns out there’s already an API for it which I didn’t know about.

3 Likes

You can use StarterGui:GetCore("ChatActive") to get whether the chat is open or not, and similarly, StarterGui:SetCore("ChatActive", bool) to forcefully open/close the chat.

3 Likes

Off topic, but this might solve my other problem, can

be used to forcefully keep chat closed? or would the player be able to re-open it?

The player would be able to re-open it by clicking the button in the topbar. For this case you’d probably just want to disable the chat window altogether.

Darn!

Thanks, I had no idea about that :slight_smile:

It sounds like you want to be using StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, bool). This will entirely remove the chat until you want to allow it back again.