Motor Sınıfı
TextBox
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Özet
Özellikler
Yöntemler
CaptureFocus():() |
ReleaseFocus(submitted: boolean):() |
Olaylar
FocusLost(enterPressed: boolean,inputThatCausedFocusLoss: InputObject):RBXScriptSignal |
Kod Örnekleri
Metin Kutusu Gizli Kelime
-- Bu kodu bir Metin Kutusunun içine bir LocalScript'e yerleştirin
local textBox = script.Parent
local secretWord = "roblox"
local colorNormal = Color3.new(1, 1, 1) -- beyaz
local colorWrong = Color3.new(1, 0, 0) -- kırmızı
local colorCorrect = Color3.new(0, 1, 0) -- yeşil
-- textBox'ın durumunu başlat
textBox.ClearTextOnFocus = true
textBox.Text = ""
textBox.Font = Enum.Font.Code
textBox.PlaceholderText = "Gizli kelime nedir?"
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 = "GİRİŞ İZNİ VERİLDİ"
textBox.BackgroundColor3 = colorCorrect
else
textBox.Text = "GİRİŞ YASAKLANDI"
textBox.BackgroundColor3 = colorWrong
end
else
-- Oyuncu Enter'a basmadan düzenlemeyi durdurdu
textBox.Text = ""
textBox.BackgroundColor3 = colorNormal
end
end
textBox.FocusLost:Connect(onFocusLost)
textBox.Focused:Connect(onFocused)API Referansı
Özellikler
CursorPosition
Kod Örnekleri
Metin Kutusu Seçimleri
local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("Seçim yok")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('Seçim şudur:"', selectedText, '"')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)FontSize
SelectionStart
Kod Örnekleri
Metin Kutusu Seçimleri
local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("Seçim yok")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('Seçim şudur:"', selectedText, '"')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)TextColor
TextColor3
Kod Örnekleri
Sesli Harf Tespit Edici
local textBox = script.Parent
local function hasVowels(str)
return str:lower():find("[aeiou]")
end
local function onTextChanged()
local text = textBox.Text
-- Sesli harfleri kontrol et
if hasVowels(text) then
textBox.TextColor3 = Color3.new(0, 0, 0) -- Siyah
else
textBox.TextColor3 = Color3.new(1, 0, 0) -- Kırmızı
end
end
textBox:GetPropertyChangedSignal("Text"):Connect(onTextChanged)TextWrap
Yöntemler
CaptureFocus
TextBox:CaptureFocus():()
Dönüşler
()
Kod Örnekleri
Metin Kutusu Odaklama
local UserInputService = game:GetService("UserInputService")
local textBox = script.Parent
local input = UserInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Q then
textBox:CaptureFocus()
end
end)ReleaseFocus
Parametreler
| Varsayılan değer: false |
Dönüşler
()
Kod Örnekleri
Metin Kutusunun Odak Kontrolünü Bırak
local UserInputService = game:GetService("UserInputService")
local textBox = script.Parent
local input = UserInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Escape and textBox.IsFocused then
textBox:ReleaseFocus()
end
end)Olaylar
Focused
Kod Örnekleri
Metin Kutusu Odak
local textBox = script.Parent
textBox.Focused:Connect(function()
print("Odaklandı!")
end)
textBox.FocusLost:Connect(function()
print("Odak kaybedildi!")
end)FocusLost
Parametreler
Kod Örnekleri
Metin Kutusu Odak
local textBox = script.Parent
textBox.Focused:Connect(function()
print("Odaklandı!")
end)
textBox.FocusLost:Connect(function()
print("Odak kaybedildi!")
end)OdakKaybı
local textBox = script.Parent
local function onFocusLost(enterPressed, inputThatCausedFocusLost)
if enterPressed then
print("Oyuncu Enter'a bastı")
else
print("Oyuncu bastı", inputThatCausedFocusLost.KeyCode)
end
end
textBox.FocusLost:Connect(onFocusLost)MetinKutusu.FokusKaybı1
local gui = script.Parent
local textBox = gui.TextBox
local function focusLost(enterPressed)
if enterPressed then
print("Enter'a basıldığı için odak kaybedildi!")
else
print("Enter'a basılmadan odak kaybedildi")
end
end
textBox.FocusLost:Connect(focusLost)