TextChatService.ChatInputBarConfiguration.TextBox is nil

Hi,

I want to be able to hook into the Focused and FocusLost events, as well as use CaptureFocus() from the TextChatService’s built-in text input bar.

According to ChatInputBarConfiguration | Roblox Creator Documentation I should be able to access the TextBox from ChatInputBarConfiguration. However, when it comes time to access that property, it always comes back as nil!

Screenshot 2023-04-19 082104

I’ve tried breakpointing at various times when it’s known for certain that the ChatInputBarConfiguration is alive and well, but nothing so far will make TextBox populate with a non-nil value.

A simple line (after fetching the TextChatService & ChatInputBarConfiguration) like:

local textBox = ChatInputBarConfiguration:WaitForChild("TextBox")

will result in infinite yielding, and anything like

ChatInputBarConfiguration.TextBox.Focused:Connect(...)

results in nil index error.

Any help would be appreciated!

Expected behavior

TextChatService.ChatInputBarConfiguration.TextBox should return a reference to the expected TextBox instance.

2 Likes

I noticed another issue where TextChatService’s version of the chat box will show a / when pressing the chat keybind, /. It’s been annoying to delete from the message, and sometimes messages will censor because this forward slash causes the filter to freak out.

The reason I bring this up here, is because I wonder if this Focused event is somehow tied into this issue I just stated.

Hopefully this issue is resolved soon. I can only imagine this issue is affecting systems that make “Typing” animations above the users head. If you can’t detect when the user may be typing, it could cause vital features to break!

1 Like

Thanks for the report! We’ve filed a ticket in our internal database.

3 Likes

Hi! ChatInputBarConfiguration.TextBox is not intended to return the default input bar TextBox. It allows you to supply your own custom TextBox that will then ‘promote’ it to automatically have the front-end logic required for chat (hotkey, sending chat messages, etc.), as well as automatically benefit from any new functionality we provide to the input bar. I noticed that this is not currently reflected in our documentation, so I’m following up with our team to make sure this is clearer. Sorry for the confusion!

May I ask what your use case is for needing to hooking into the Focus events or needing to call CaptureFocus()? We are working on new APIs to support popular use cases so would be good to understand your use case.

2 Likes

Thanks for raising–this issue has been raised here. We have a fix in which will be included in our release next week.

4 Likes

For me, it’s to have an autocomplete system for TextChatService commands. There’s no way to interact with the textbox, so it is very hard to do that.

What does that mean? Does the property override the textbox, or does it just pass all changes from the CoreGui one to the one you put, so you can connect to .Focused?

Currently in our game using the legacy Chat module, we have a UI button added in the area of the chat window that when pressed will both open the chat window and focus the text box. The button also reacts when the chat window/input box becomes focused or unfocused by other means. We’d like to replicate this behavior after migrating to the TextChatService.

Does creating a TextBox as-is and promoting it with the ChatInputBarConfiguration create a stock-TextChatService-like TextBox as seen in the default UI or do I always need to define my own configuration?

This as well.

1 Like

It doesnt look like the ChatInputBarConfiguration.TextBox property is enabled yet. We are still writing documentation that explains the properties behavior, but I can give a quick summary of its intended use cases.

ChatInputBarConfiguration.TextBox is a property that references designated TextBox Instance that will be used to send messages on behalf of the user. This property will only accept TextBox instances.

The TextBox property is intended to assist developers to create custom chat uis. After creating a user interface for chat, they can set ChatInputBarConfiguration.TextBox to their custom textbox. The developer does not need to write any code for the following behaviors after setting the property:

  • When a Player uses your TextBox, when they press Return, it will send the message to ChatInputBarConfiguration.TargetTextChannel.
  • The custom developer-provided TextBox will behavior similarly to the default TextChatService TextBox. This means it will clear the Text after sending a message.
  • Using the chat hotkey (currently set to / on U.S. keyboards) will automatically focus the TextBox.

Some limitations are imposed on the TextBox when it is promoted as ChatInputBarConfiguration.TextBox. Lua code won’t be able to manually focus/unfocus the TextBox. Likewise writing to the Text and other properties may not function while it is currently promoted. Appearance, location, and layout properties of course would still be functional for developers so they can deeply integrate their custom UI into their experiences.


It doesn’t sound like this property will provide the behaviors you’re looking for. We have been planning a few properties to let the developer know when the default text box is focused (could be useful for stuff like typing indicators) but even that would not support an autocomplete function as you’ve described.


We have interest internally to create an autocomplete function for TextChatCommands. We believe the current API for TextChatCommands would lend itself well to have a built-in option for this. I’m not sure if this work is scheduled yet nor can I give any estimates or promises right now.

Unfortunately, without creating your own chat UI from scratch, it would not be possible to extend the default UI this way.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.