TextBox

Artık kullanılmayanları göster

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.

Bir Metin Kutusu , oyuncunun metin girişi yapmasına izin verir.Bir tek TextBox'un tıklayarak, dokunarak veya oyun kumandası seçimiyle odaklanması dışında, benzer şekilde davranır TextButton .Odaklanırken, oyuncu Text özelliğini değiştirmek için bir klavye kullanabilir.

  • Metin yoksa, PlaceholderText görünecektir. Bu, oyunculara girmeleri gereken veri türü veya formatı konusunda yararlı bir uyarıdır.
  • Varsayılan olarak, ClearTextOnFocus özelliği etkinleştirilir ve bir TextBox odaklandığında mevcut bir metin olmadığından emin olur.oyuncutarafından düzenlenebilecek metin için bu istenmeyebilir.
  • The MultiLine özelliği, oyuncuların yeni satır karakterleriyle birden fazla satır metin girmesine izin verir (\n).

The ContextActionService onur TextBox tuş kombinasyonlarını ve otomatik olarak anahtar basma olaylarının ContextActionService:BindAction() ile bağlı eylemlere geçmesini engelleyecektir.UserInputService.InputBegan ve ilgili olaylar, bir TextBox odakta olduğu sürece hala ateşlenecek.

Odak Durumu

Bir TextBox'un odak durumunu tespit edip değiştirmek mümkündür:

  • Bir diyalog göründüğünde CaptureFocus kullanabilirsiniz, böylece oyuncu mevcut olduğunda bir TextBox'a tıklamak zorunda kalmaz; bu işlevi kullanarak bir TextBox'a odaklanmak için belirli bir anahtarı bağlamak için ContextActionService:BindAction() kullanabilirsiniz.Bir TextBox odaklanınca, Focused etkinliği ateşlenir.
  • Belli bir TextBox'un odakta olup olmadığını IsFocused kullanarak tespit edebilirsiniz. Alternatif olarak, herhangi bir TextBox'un odakta olup olmadığını kontrol etmek için UserInputService:GetFocusedTextBox() kullanılabilir.
  • Oyuncu metin girişini bitirdiğinde, etkinliği ateşlenir, kullanıcının odak kaybına neden olan ile birlikte metin göndermek için basıp basmadığını gösterir.Mobil ve konsolda ekran klavyelerini kullanırken, ReturnPressedFromOnScreenKeyboard da ateşlenebilir.
  • oynanışsırasında daha önemli bir konu ortaya çıkarsa, bir oyuncunun klavye girişi oyununuza geri döner, TextBox'un ReleaseFocus kısmını öyle yapabilirsiniz.

Metin Düzenleme

Bir TextBox, CursorPosition ve SelectionStart özellikleri aracılığıyla metin seçimi destekler.GetPropertyChangedSignal kullanarak, bir seçimin değiştiğini tespit edebilirsiniz.Ayrıca, oyuncuların bir TextBox içinde metin kopyalayıp yapıştırması ve temel klip desteği sağlaması mümkündür.

Metin Filtreleme Bildirimi Oyuncudan oyuncuya iletişimi kolaylaştıran metinler, özel sohbet veya isim etiketleri gibi, bu tür bir metni doğru bir şekilde filtrelemelidir TextService:FilterStringAsync() veya Chat:FilterStringAsync() .Bu doğru yapılmazsa, oyununuz moderasyon aksiyonalabilir.

Kod Örnekleri

This code sample creates a password-like interface for a TextBox, giving visual feedback on the player's input.

TextBox Secret Word

-- Place this code in a LocalScript inside a TextBox
local textBox = script.Parent
local secretWord = "roblox"
local colorNormal = Color3.new(1, 1, 1) -- white
local colorWrong = Color3.new(1, 0, 0) -- red
local colorCorrect = Color3.new(0, 1, 0) -- green
-- Initialize the state of the textBox
textBox.ClearTextOnFocus = true
textBox.Text = ""
textBox.Font = Enum.Font.Code
textBox.PlaceholderText = "What is the secret word?"
textBox.BackgroundColor3 = colorNormal
local function onFocused()
textBox.BackgroundColor3 = colorNormal
end
local function onFocusLost(enterPressed, _inputObject)
if enterPressed then
local guess = textBox.Text
if guess == secretWord then
textBox.Text = "ACCESS GRANTED"
textBox.BackgroundColor3 = colorCorrect
else
textBox.Text = "ACCESS DENIED"
textBox.BackgroundColor3 = colorWrong
end
else
-- The player stopped editing without pressing Enter
textBox.Text = ""
textBox.BackgroundColor3 = colorNormal
end
end
textBox.FocusLost:Connect(onFocusLost)
textBox.Focused:Connect(onFocused)

Özet

Özellikler

Şuradan alınan Özellikler: GuiObject

Özellikler

Şuradan alınan Özellikler: GuiBase2d

Özellikler

Yöntemler

Şuradan alınan Yöntemler: GuiObject

Yöntemler

Olaylar

Şuradan alınan Olaylar: GuiObject

Olaylar

Şuradan alınan Olaylar: GuiBase2d

Olaylar

Özellikler

ClearTextOnFocus

Paralel oku

ContentText

Salt Okunur
Çoğaltılmamış
Paralel oku

CursorPosition

Paralel oku

Kod Örnekleri

Metin Kutusu Seçimleri

local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("No selection")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('The selection is:"', selectedText, '"')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)
Gizli
Çoğaltılmamış
Paralel oku

Kod Örnekleri

Cycle Font

local textLabel = script.Parent
while true do
-- Iterate over all the different fonts
for _, font in pairs(Enum.Font:GetEnumItems()) do
textLabel.Font = font
textLabel.Text = font.Name
task.wait(1)
end
end
Tüm Fontları Göster

local frame = script.Parent
-- Her bir fontu gösteren bir TextLabel oluştur
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Metin özelliklerini ayarla
textLabel.Text = font.Name
textLabel.Font = font
-- Bazı renderleme özellikleri
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Metnin yüksekliğine eşit olan çerçeveyi boyutlandır
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Ebeveyn çerçeye ekleyin
textLabel.Parent = frame
end
-- Çerçeveleri bir listedeki düzenle (eğer henüz değilse)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
end

FontFace

Paralel oku

LineHeight

Paralel oku

MaxVisibleGraphemes

Paralel oku

MultiLine

Paralel oku

OpenTypeFeatures

Paralel oku

OpenTypeFeaturesError

Salt Okunur
Çoğaltılmamış
Paralel oku

PlaceholderColor3

Paralel oku

PlaceholderText

Paralel oku

RichText

Paralel oku

SelectionStart

Paralel oku

Kod Örnekleri

Metin Kutusu Seçimleri

local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("No selection")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('The selection is:"', selectedText, '"')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)

ShowNativeInput

Paralel oku

Text

Paralel oku

Kod Örnekleri

Fading Banner

local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Welcome to my game!",
"Be sure to have fun!",
"Please give suggestions!",
"Be nice to other players!",
"Don't grief other players!",
"Check out the shop!",
"Tip: Don't die!",
}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local RNG = Random.new()
local fadeIn = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 0,
})
local fadeOut = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 1,
})
local lastIndex
while true do
-- Step 0: Fade out before doing anything
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Step 1: pick content that wasn't the last displayed
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Make sure we don't show the same thing next time
lastIndex = index
-- Step 2: show the content
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
end
“Kaboom!” Metni

local textLabel = script.Parent
textLabel.Text = "Kaboom!"
while true do
for size = 5, 100, 5 do
textLabel.TextSize = size
textLabel.TextTransparency = size / 100
task.wait()
end
task.wait(1)
end
Tüm Fontları Göster

local frame = script.Parent
-- Her bir fontu gösteren bir TextLabel oluştur
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Metin özelliklerini ayarla
textLabel.Text = font.Name
textLabel.Font = font
-- Bazı renderleme özellikleri
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Metnin yüksekliğine eşit olan çerçeveyi boyutlandır
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Ebeveyn çerçeye ekleyin
textLabel.Parent = frame
end
-- Çerçeveleri bir listedeki düzenle (eğer henüz değilse)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
end
Long Text Wrapping

local textLabel = script.Parent
-- This text wrapping demo is best shown on a 200x50 px rectangle
textLabel.Size = UDim2.new(0, 200, 0, 50)
-- Some content to spell out
local content = "Here's a long string of words that will "
.. "eventually exceed the UI element's width "
.. "and form line breaks. Useful for paragraphs "
.. "that are really long."
-- A function that will spell text out two characters at a time
local function spellTheText()
-- Iterate from 1 to the length of our content
for i = 1, content:len() do
-- Get a substring of our content: 1 to i
textLabel.Text = content:sub(1, i)
-- Color the text if it doesn't fit in our box
if textLabel.TextFits then
textLabel.TextColor3 = Color3.new(0, 0, 0) -- Black
else
textLabel.TextColor3 = Color3.new(1, 0, 0) -- Red
end
-- Wait a brief moment on even lengths
if i % 2 == 0 then
task.wait()
end
end
end
while true do
-- Spell the text with scale/wrap off
textLabel.TextWrapped = false
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with wrap on
textLabel.TextWrapped = true
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with text scaling on
-- Note: Text turns red (TextFits = false) once text has to be
-- scaled down in order to fit within the UI element.
textLabel.TextScaled = true
-- Note: TextWrapped is enabled implicitly when TextScaled = true
--textLabel.TextWrapped = true
spellTheText()
task.wait(1)
end
Emoji in Text

local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "I am feeling " .. mood .. "! " .. face
task.wait(1)
end
end

TextBounds

Salt Okunur
Çoğaltılmamış
Paralel oku

Kod Örnekleri

Dynamic TextBox Size

local textBox = script.Parent
-- The smallest the TextBox will go
local minWidth, minHeight = 10, 10
-- Set alignment so our text doesn't wobble a bit while we type
textBox.TextXAlignment = Enum.TextXAlignment.Left
textBox.TextYAlignment = Enum.TextYAlignment.Top
local function updateSize()
textBox.Size = UDim2.new(0, math.max(minWidth, textBox.TextBounds.X), 0, math.max(minHeight, textBox.TextBounds.Y))
end
textBox:GetPropertyChangedSignal("TextBounds"):Connect(updateSize)

TextColor3

Paralel oku

Kod Örnekleri

Vowel Detector

local textBox = script.Parent
local function hasVowels(str)
return str:lower():find("[aeiou]")
end
local function onTextChanged()
local text = textBox.Text
-- Check for vowels
if hasVowels(text) then
textBox.TextColor3 = Color3.new(0, 0, 0) -- Black
else
textBox.TextColor3 = Color3.new(1, 0, 0) -- Red
end
end
textBox:GetPropertyChangedSignal("Text"):Connect(onTextChanged)
TextBox Secret Word

-- Place this code in a LocalScript inside a TextBox
local textBox = script.Parent
local secretWord = "roblox"
local colorNormal = Color3.new(1, 1, 1) -- white
local colorWrong = Color3.new(1, 0, 0) -- red
local colorCorrect = Color3.new(0, 1, 0) -- green
-- Initialize the state of the textBox
textBox.ClearTextOnFocus = true
textBox.Text = ""
textBox.Font = Enum.Font.Code
textBox.PlaceholderText = "What is the secret word?"
textBox.BackgroundColor3 = colorNormal
local function onFocused()
textBox.BackgroundColor3 = colorNormal
end
local function onFocusLost(enterPressed, _inputObject)
if enterPressed then
local guess = textBox.Text
if guess == secretWord then
textBox.Text = "ACCESS GRANTED"
textBox.BackgroundColor3 = colorCorrect
else
textBox.Text = "ACCESS DENIED"
textBox.BackgroundColor3 = colorWrong
end
else
-- The player stopped editing without pressing Enter
textBox.Text = ""
textBox.BackgroundColor3 = colorNormal
end
end
textBox.FocusLost:Connect(onFocusLost)
textBox.Focused:Connect(onFocused)
Countdown Text

-- Place this code in a LocalScript within a TextLabel/TextButton
local textLabel = script.Parent
-- Some colors we'll use with TextColor3
local colorNormal = Color3.new(0, 0, 0) -- black
local colorSoon = Color3.new(1, 0.5, 0.5) -- red
local colorDone = Color3.new(0.5, 1, 0.5) -- green
-- Loop infinitely
while true do
-- Count backwards from 10 to 1
for i = 10, 1, -1 do
-- Set the text
textLabel.Text = "Time: " .. i
-- Set the color based on how much time is left
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "GO!"
textLabel.TextColor3 = colorDone
task.wait(2)
end
Oyun Durumu Metni

local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- ReplicatedStorage'a "GameState" adlı bir StringValue yerleştir
local vGameState = ReplicatedStorage:WaitForChild("GameState")
-- Bu kodu bir TextLabel'e yerleştir
local textLabel = script.Parent
-- TextColor3 ile kullanacağımız bazı renkler
local colorNormal = Color3.new(0, 0, 0) -- sızık
local colorCountdown = Color3.new(1, 0.5, 0) -- turuncu
local colorRound = Color3.new(0.25, 0.25, 1) -- mavi
-- Bu işlevi çalıştıracağız TextLabel'i devlet olarak güncellemek için,
-- oyun değişiklikleri.
local function update()
-- Metni güncelle
textLabel.Text = "State: " .. vGameState.Value
-- Mevcut oyun durumuna göre metin rengini ayarlayın
if vGameState.Value == "Countdown" then
textLabel.TextColor3 = colorCountdown
elseif vGameState.Value == "Round" then
textLabel.TextColor3 = colorRound
else
textLabel.TextColor3 = colorNormal
end
end
-- Desen: başladığımızda ve vGameState değiştiğinde bir kez güncellenir
-- Her zaman en güncel GameState'i görmeliyiz.
update()
vGameState.Changed:Connect(update)

TextDirection

Paralel oku

TextEditable

Paralel oku

TextFits

Salt Okunur
Çoğaltılmamış
Paralel oku

TextScaled

Paralel oku

Kod Örnekleri

Long Text Wrapping

local textLabel = script.Parent
-- This text wrapping demo is best shown on a 200x50 px rectangle
textLabel.Size = UDim2.new(0, 200, 0, 50)
-- Some content to spell out
local content = "Here's a long string of words that will "
.. "eventually exceed the UI element's width "
.. "and form line breaks. Useful for paragraphs "
.. "that are really long."
-- A function that will spell text out two characters at a time
local function spellTheText()
-- Iterate from 1 to the length of our content
for i = 1, content:len() do
-- Get a substring of our content: 1 to i
textLabel.Text = content:sub(1, i)
-- Color the text if it doesn't fit in our box
if textLabel.TextFits then
textLabel.TextColor3 = Color3.new(0, 0, 0) -- Black
else
textLabel.TextColor3 = Color3.new(1, 0, 0) -- Red
end
-- Wait a brief moment on even lengths
if i % 2 == 0 then
task.wait()
end
end
end
while true do
-- Spell the text with scale/wrap off
textLabel.TextWrapped = false
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with wrap on
textLabel.TextWrapped = true
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with text scaling on
-- Note: Text turns red (TextFits = false) once text has to be
-- scaled down in order to fit within the UI element.
textLabel.TextScaled = true
-- Note: TextWrapped is enabled implicitly when TextScaled = true
--textLabel.TextWrapped = true
spellTheText()
task.wait(1)
end

TextSize

Paralel oku

Kod Örnekleri

“Kaboom!” Metni

local textLabel = script.Parent
textLabel.Text = "Kaboom!"
while true do
for size = 5, 100, 5 do
textLabel.TextSize = size
textLabel.TextTransparency = size / 100
task.wait()
end
task.wait(1)
end

TextStrokeColor3

Paralel oku

Kod Örnekleri

Text Highlight Oscillation

local textLabel = script.Parent
-- How fast the highlight ought to blink
local freq = 2
-- Set to yellow highlight color
textLabel.TextStrokeColor3 = Color3.new(1, 1, 0)
while true do
-- math.sin oscillates from -1 to 1, so we change the range to 0 to 1:
local transparency = math.sin(workspace.DistributedGameTime * math.pi * freq) * 0.5 + 0.5
textLabel.TextStrokeTransparency = transparency
task.wait()
end

TextStrokeTransparency

Paralel oku

Kod Örnekleri

Text Highlight Oscillation

local textLabel = script.Parent
-- How fast the highlight ought to blink
local freq = 2
-- Set to yellow highlight color
textLabel.TextStrokeColor3 = Color3.new(1, 1, 0)
while true do
-- math.sin oscillates from -1 to 1, so we change the range to 0 to 1:
local transparency = math.sin(workspace.DistributedGameTime * math.pi * freq) * 0.5 + 0.5
textLabel.TextStrokeTransparency = transparency
task.wait()
end

TextTransparency

Paralel oku

Kod Örnekleri

Fading Banner

local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Welcome to my game!",
"Be sure to have fun!",
"Please give suggestions!",
"Be nice to other players!",
"Don't grief other players!",
"Check out the shop!",
"Tip: Don't die!",
}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local RNG = Random.new()
local fadeIn = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 0,
})
local fadeOut = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 1,
})
local lastIndex
while true do
-- Step 0: Fade out before doing anything
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Step 1: pick content that wasn't the last displayed
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Make sure we don't show the same thing next time
lastIndex = index
-- Step 2: show the content
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
end
“Kaboom!” Metni

local textLabel = script.Parent
textLabel.Text = "Kaboom!"
while true do
for size = 5, 100, 5 do
textLabel.TextSize = size
textLabel.TextTransparency = size / 100
task.wait()
end
task.wait(1)
end

TextTruncate

Paralel oku

TextWrapped

Paralel oku

Kod Örnekleri

Long Text Wrapping

local textLabel = script.Parent
-- This text wrapping demo is best shown on a 200x50 px rectangle
textLabel.Size = UDim2.new(0, 200, 0, 50)
-- Some content to spell out
local content = "Here's a long string of words that will "
.. "eventually exceed the UI element's width "
.. "and form line breaks. Useful for paragraphs "
.. "that are really long."
-- A function that will spell text out two characters at a time
local function spellTheText()
-- Iterate from 1 to the length of our content
for i = 1, content:len() do
-- Get a substring of our content: 1 to i
textLabel.Text = content:sub(1, i)
-- Color the text if it doesn't fit in our box
if textLabel.TextFits then
textLabel.TextColor3 = Color3.new(0, 0, 0) -- Black
else
textLabel.TextColor3 = Color3.new(1, 0, 0) -- Red
end
-- Wait a brief moment on even lengths
if i % 2 == 0 then
task.wait()
end
end
end
while true do
-- Spell the text with scale/wrap off
textLabel.TextWrapped = false
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with wrap on
textLabel.TextWrapped = true
textLabel.TextScaled = false
spellTheText()
task.wait(1)
-- Spell the text with text scaling on
-- Note: Text turns red (TextFits = false) once text has to be
-- scaled down in order to fit within the UI element.
textLabel.TextScaled = true
-- Note: TextWrapped is enabled implicitly when TextScaled = true
--textLabel.TextWrapped = true
spellTheText()
task.wait(1)
end

TextXAlignment

Paralel oku

Kod Örnekleri

Metin Uzmanlığı

-- Bunu bir TextLabel/TextButton/TextBox içindeki YerelScript'e yapıştır
local textLabel = script.Parent
local function setAlignment(xAlign, yAlign)
textLabel.TextXAlignment = xAlign
textLabel.TextYAlignment = yAlign
textLabel.Text = xAlign.Name .. " + " .. yAlign.Name
end
while true do
-- Hem TextXAlignment hem de TextYAlignment sayısal öğeler üzerinde döngü yap
for _, yAlign in pairs(Enum.TextYAlignment:GetEnumItems()) do
for _, xAlign in pairs(Enum.TextXAlignment:GetEnumItems()) do
setAlignment(xAlign, yAlign)
task.wait(1)
end
end
end

TextYAlignment

Paralel oku

Kod Örnekleri

Metin Uzmanlığı

-- Bunu bir TextLabel/TextButton/TextBox içindeki YerelScript'e yapıştır
local textLabel = script.Parent
local function setAlignment(xAlign, yAlign)
textLabel.TextXAlignment = xAlign
textLabel.TextYAlignment = yAlign
textLabel.Text = xAlign.Name .. " + " .. yAlign.Name
end
while true do
-- Hem TextXAlignment hem de TextYAlignment sayısal öğeler üzerinde döngü yap
for _, yAlign in pairs(Enum.TextYAlignment:GetEnumItems()) do
for _, xAlign in pairs(Enum.TextXAlignment:GetEnumItems()) do
setAlignment(xAlign, yAlign)
task.wait(1)
end
end
end

Yöntemler

CaptureFocus

()

Dönüşler

()

Kod Örnekleri

TextBox:CaptureFocus

local ContextActionService = game:GetService("ContextActionService")
local ACTION_NAME = "FocusTheTextBox"
local textBox = script.Parent
local function handleAction(actionName, inputState, _inputObject)
if actionName == ACTION_NAME and inputState == Enum.UserInputState.End then
textBox:CaptureFocus()
end
end
ContextActionService:BindAction(ACTION_NAME, handleAction, false, Enum.KeyCode.Q)

IsFocused


Dönüşler

ReleaseFocus

()

Parametreler

submitted: boolean
Varsayılan değer: false

Dönüşler

()

Kod Örnekleri

TextBox:ReleaseFocus

local textBox = script.Parent
local function onFocused()
task.wait(5)
textBox:ReleaseFocus()
end
textBox.Focused:Connect(onFocused)

Olaylar

FocusLost

Parametreler

enterPressed: boolean
inputThatCausedFocusLoss: InputObject

Kod Örnekleri

TextBox.FocusLost1

local gui = script.Parent
local textBox = gui.TextBox
local function focusLost(enterPressed)
if enterPressed then
print("Focus was lost because enter was pressed!")
else
print("Focus was lost without enter being pressed")
end
end
textBox.FocusLost:Connect(focusLost)
Odak Kaybı

local textBox = script.Parent
local function onFocusLost(enterPressed, inputThatCausedFocusLost)
if enterPressed then
print("Player pressed Enter")
else
print("Player pressed", inputThatCausedFocusLost.KeyCode)
end
end
textBox.FocusLost:Connect(onFocusLost)

Focused


Kod Örnekleri

Focus

local textBox = script.Parent
local function onFocused()
print("Focused")
end
textBox.Focused:Connect(onFocused)

ReturnPressedFromOnScreenKeyboard