Löve Frames - The Textinput Object
Return to Index
Information
The text input object receives text from the user via keyboard. The text input object supports both single-line and multi-line input.
Example Use
local frame = loveframes.Create("frame")
frame:SetName("Text Input")
frame:SetSize(500, 90)
frame:CenterWithinArea(unpack(demo.centerarea))
	
local textinput = loveframes.Create("textinput", frame)
textinput:SetPos(5, 30)
textinput:SetWidth(490)
textinput.OnEnter = function(object)
	if not textinput.multiline then
		object:Clear()
	end
end
textinput:SetFont(love.graphics.newFont(12))
		
local togglebutton = loveframes.Create("button", frame)
togglebutton:SetPos(5, 60)
togglebutton:SetWidth(490)
togglebutton:SetText("Toggle Multiline")
togglebutton.OnClick = function(object)
	if textinput.multiline then
		frame:SetHeight(90)
		frame:Center()
		togglebutton:SetPos(5, 60)
		textinput:SetMultiline(false)
		textinput:SetHeight(25)
		textinput:SetText("")
		frame:CenterWithinArea(unpack(demo.centerarea))
	else
		frame:SetHeight(365)
		frame:Center()
		togglebutton:SetPos(5, 335)
		textinput:SetMultiline(true)
		textinput:SetHeight(300)
		textinput:SetText("")
		frame:CenterWithinArea(unpack(demo.centerarea))
	end
end
Event Callbacks
OnEnter - Called when enter/return is pressed when the object has focus.
- Arguments passed: self [object], self text [string]
local textinput = loveframes.Create("textinput")
textinput.OnEnter = function(object, text)
	print(text)
end
OnTextChanged - Called when the object's text is changed.
- Arguments passed: self [object], text entered [string] or modifier key [string]
local textinput = loveframes.Create("textinput")
textinput.OnTextChanged = function(object, text)
	print(text)
end
OnFocusGained - Called when the object gains focus.
- Arguments passed: self [object]
local textinput = loveframes.Create("textinput")
textinput.OnFocusGained = function(object)
	print("The object has gained focus.")
end
OnFocusLost - Called when the object loses focus.
- Arguments passed: self [object]
local textinput = loveframes.Create("textinput")
textinput.OnFocusLost = function(object)
	print("The object has lost focus.")
end
Methods
RunKey - Called when a key is pressed and needs to be processed into text.
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:RunKey(key[string], unicode[number])
MoveIndicator - Moves the object's indicator
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:MoveIndicator(num[number], exact[boolean])
UpdateIndicator - Updates the object's indicator
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:UpdateIndicator()
AddIntoText - Adds text into the object's text at a specific location
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:AddIntoText(text[string], position[number])
RemoveFromText - Removes a chracter from the object's text
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:AddIntoText(position[number])
GetTextCollisions - Gets collisions with the object's text and the mouse cursor
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:GetTextCollisions(x[number], y[number])
PositionText - Positions the object's text
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
object:PositionText()
SetTextOffsetX - Sets the object's text x offset
object:SetTextOffsetX(xoffset[number])
SetTextOffsetY - Sets the object's text y offset
object:SetTextOffsetY(yoffset[number])
SetFont - Sets the object's font
object:SetFont(font[font])
GetFont - Gets the object's font
- Returns 1 value: font [font]
local font = object:GetFont()
SetFocus - Sets the object's focus
object:SetFocus(focus[true])
GetFocus - Gets the object's focus
- Returns 1 value: focus [boolean]
local focus = object:GetFocus()
GetIndicatorVisibility - Gets the object's indicator visibility
- Returns 1 value: visibility [boolean]
local indicatorvisibility = object:GetIndicatorVisibility()
SetLimit - Sets the maximum number of characters the object's text can have
object:SetLimit(limit[number])
SetUsable - Sets what characters can be used in the object's text
object:SetUsable(usable[table])
GetUsable - Gets what characters can be used in the object's text
- Returns 1 value: usable [table]
local usable = object:GetUsable()
SetUnsable - Sets what characters can not be used in the object's text
object:SetUnusable(unusable[table])
GetUnsable - Gets what characters can not be used in the object's text
- Returns 1 value: unusable [table]
local unusable = object:GetUnsable()
Clear - Clears the object's text
object:Clear()
SetText - Sets the object's text
object:SetText(text[string])
GetText - Gets the object's text
local text = object:GetText()
SetMultiline - Enables or disables multiline input mode
object:SetMultiline(multiline[bool])
GetMultiline - Gets whether or not the object is using multiline input
- Returns 1 value: multiline [bool]
local multiline = object:GetMultiline()
GetVerticalScrollBody - Gets the object's vertical scroll body
- Returns 1 value: vscrollbody [object]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local vscrollbody = object:GetVerticalScrollBody()
GetHorizontalScrollBody - Gets the object's horizontal scroll body
- Returns 1 value: hscrollbody [object]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local hscrollbody = object:GetHorizontalScrollBody()
HasVerticalScrollBody - Checks if the object has a vertical scroll body
- Returns 1 value: hasvscrollbody [bool]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local hasvscrollbody = object:HasVerticalScrollBody()
HasHorizontalScrollBody - Checks if the object has a horizontal scroll body
- Returns 1 value: hashscrollbody [bool]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local hashscrollbody = object:HasHorizontalScrollBody()
GetLineNumbersPanel - Gets the object's line numbers panel
- Returns 1 value: panel [object]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local panel = object:GetLineNumbersPanel()
GetTextX - Gets the x position of the object's text
- Returns 1 value: textx [number]
local textx = object:GetTextX()
GetTextY - Gets the y position of the object's text
- Returns 1 value: texty [number]
local texty = object:GetTextY()
IsAllTextSelected - Gets whether or not all of the object's text is selected
- Returns 1 value: alltextselected [bool]
local alltextselected = object:IsAllTextSelected()
GetLines - Gets the object's line data
- Returns 1 value: lines [table]
local lines = object:GetLines()
GetOffsetX - Gets object's x offset
- Returns 1 value: offsetx [number]
local offsetx = object:GetOffsetX()
GetOffsetY - Gets object's y offset
- Returns 1 value: offsety [number]
local offsety = object:GetOffsetY()
GetIndicatorX - Gets object's indcator x position
- Returns 1 value: indicatorx [number]
local indicatorx = object:GetIndicatorX()
GetIndicatorY - Gets object's indcator y position
- Returns 1 value: indicatory [number]
local indicatory = object:GetIndicatorY()
ShowLineNumbers - Toggles the line numbers panel
object:ShowLineNumbers(show_line_numbers[bool])
GetItemWidth - Gets object's item width
- Returns 1 value: itemwidth [number]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local itemwidth = object:GetItemWidth()
GetItemHeight - Gets object's item height
- Returns 1 value: itemheight [number]
- Note: This method is used by the object internally. You should not use it unless you know what you are doing.
local itemheight = object:GetItemHeight()
SetTabReplacement - Sets what characters should be used to replace tab characters
object:SetTabReplacement(tabreplacement[string])
GetTabReplacement - Gets object's tab replacement
- Returns 1 value: tab replacement [string]
local tabreplacement = object:GetTabReplacement()
SetEditable - Sets whether the object is editable or not
object:SetEditable(editable[bool])
GetEditable - Gets whether the object is editable or not
- Returns 1 value: editable [bool]
local editable = object:GetEditable()
SetButtonScrollAmount - Sets the amount that the object's scroll buttons will scroll the object's list items by
object:SetButtonScrollAmount(scrollamount[number])
GetButtonScrollAmount - Gets the object's scroll button scroll amount
- Returns 1 value: scrollamount [number]
local scrollamount = object:GetButtonScrollAmount()
SetMouseWheelScrollAmount - Sets the amount that the mouse wheel will scroll the object's list items by
object:SetMouseWheelScrollAmount(scrollamount[number])
GetMouseWheelScrollAmount - Gets the mouse wheel's scroll amount
- Returns 1 value: scroll amount [number]
local scrollamount = object:GetMouseWheelScrollAmount()
SetAutoScroll - Sets whether or not the object should autoscroll when in multiline mode
object:SetAutoScroll(autoscroll[bool])
GetAutoScroll - Gets whether or not the object should autoscroll when in multiline mode
- Returns 1 value: autoscroll [boolean]
local autoscroll = object:GetAutoScroll()
SetRepeatDelay - Sets the delay before the object begins to repeat the key that is being held down
object:SetRepeatDelay(delay[number])
GetRepeatDelay - Gets the object's repeat delay
- Returns 1 value: delay [number]
local delay = object:GetRepeatDelay()
SetValue - Sets the object's value
- Note: This method is an alias of SetText(text)
object:SetValue(value)
GetValue - Gets the object's value
- Returns 1 value: value [string]
- Note: This method is an alias of GetText()
local value = object:GetValue()
Copy - Copies the object's text to the clipboard
object:Copy()
Paste - Sets the object's text to the contents of the clipboard
object:Paste()
SelectAll - Selects all of the object's text
object:SelectAll()
DeselctAll - De-selects all of the object's text
object:DeselctAll()
SetMasked - Sets whether or not the object should mask its text
object:SetMasked(masked[bool])
GetMasked - Gets whether or not the object should mask its text
- Returns 1 value: masked [bool]
local masked = object:GetMasked()
SetMaskChar - Sets the character the object will use to mask its text
object:SetMaskChar(char[string])
GetMaskChar - Gets the character the object will use to mask its text
- Returns 1 value: maskchar [string]
local maskchar = object:GetMaskChar()
SetPlaceholderText - Sets the object's placeholder text
object:SetPlaceholderText(placeholder_text[string])
GetPlaceholderText - Gets the object's placeholder text
- Returns 1 value: placeholder_text [string]
local placeholder_text = object:GetPlaceholderText()