Reliably Capturing TextBox Focus Inside Studio

Hello! I’m currently working on a plugin. I am trying to make the player “focused” on a TextBox, however there is a problem:
Whenever I focus the player in the TextBox through the code, Studio bugs out. For example, you can type as expected, but hitting Backspace will delete whatever you selected. Modifier keys also do not work. O and I are not working either. Instead, they move your camera.

Here is the code I am using:

local TextBox = widget.TextBox
local TextButton = widget.TextButton

local function CaptureFocus()
    TextBox:CaptureFocus()
end

TextButton.Activated:Connect(CaptureFocus)

Help would be appreciated, if there is something I am missing here. Thanks! :slightly_smiling_face:

1 Like

if ill be honest, im not having the same issue. Whats widget?

widget is basically the window of your Plugin.


Yes I am working on a Team Create Chat Plugin, but message editing is basically impossible without being able to reliably capture focus on a TextBox.

for that case, for the widget id try widget:CaptureFocus(). Remember to do ReleaseFocus() when done

2 Likes

widget:CaptureFocus()? Are you sure that’s a real thing?
image

Widgets are PluginGuis.

1 Like

Do you mind sending me your hierarchy? Almost tweaked out since you have to create something and then you can do both either.

There’s a lot of stuff so I’ll send what I can. :joy:
Dropdown is the Frame that handles the button interactions. Dropdown.Edit: TextButton → Focus on aaa.MessageBox


what about using UserInputService with the input and processed?

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, proc)
    if proc then return end
    --// the rest of your text thingy code
end)

lowk not sure if that will work

wait aint that is your doing something in game only

Not sure. I will be able to try the code tomorrow because I have to go now. Check this topic if you’re still gonna be around tomorrow.

On the other hand, you are saying use UserInputService and detect the mouse position relative to the button? Just a reminder that this is for a plugin. Yet again, UserInputService is unreliable in plugins. I will try though.

I dont think it would work personally, idk why I decided to say that

Old topic here, but the issue was that the TextBox was not Interactable.

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