I’m having a lot of work and I’m facing some technical limitations to be able to simulate an in-game data entry form, like this:
For example, I am binding the TAB key to advance to the next field, however, apparently, the BindAction is not respecting this association when the focus is within a field.
local ContextActionService = game:GetService("ContextActionService")
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("ScreenGui")
local Frame = Gui:WaitForChild('Frame')
local Row1 = Frame:WaitForChild('Row1')
local Row2 = Frame:WaitForChild('Row2')
local Row3 = Frame:WaitForChild('Row3')
Row1.TextBox:CaptureFocus()
ContextActionService:BindAction('Tab',
function(ActionName, InputState, InputObject)
if InputState == Enum.UserInputState.Begin then
Row2.TextBox:CaptureFocus() -- tab key not working
end
end,
false, Enum.KeyCode.Tab)
If anyone wants to look, here is this project:
Baseplate.rbxl (39.9 KB)
Anyway, I ask if there are any plugins or scripts ready to facilitate the entry of data from a form?
ContextActionService
for some reason doesn’t allow us to overwrite the Enum.KeyCode.Tab
for the playerlist. It’s annoying but I can’t find a way to disable it, unless you disable the playerlist.
I would try using UserInputService | Roblox Creator Documentation with the gameProcessed
parameter instead.
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("ScreenGui")
local Frame = Gui:WaitForChild('Frame')
local focusOrder = {
Frame:WaitForChild('Row1'):WaitForChild("TextBox"),
Frame:WaitForChild('Row2'):WaitForChild("TextBox"),
Frame:WaitForChild('Row3'):WaitForChild("TextBox")
}
local focus = focusOrder[1]
local focusIndex = 0
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.Tab and gameProcessed then
if focus:IsFocused() then focus:ReleaseFocus() end
focusIndex = if focusIndex < #focusOrder then focusIndex+1 else 1
focus = focusOrder[focusIndex]
focus:CaptureFocus()
end
end)
1 Like
Thanks, that’s what I’m already doing to get around this limitation.
Still, there are some weird bugs, like when trying to use Shift+Tab to get back the fields, but for some weird reason, sometimes InputEndeded
is being fired for the Shift key, even though it hasn’t been physically released…
I’ll try to search a little more…
This is the same thing with Enum.KeyCode.Tab
. It’s a CoreScript and not accessible or modifiable for the developer. There is no work-around because Roblox does not provide an API or way to fork it.
1 Like