-
Notifications
You must be signed in to change notification settings - Fork 78
(API) Text Input
The text input object receives text from the user via keyboard. The text input object supports both single-line and multi-line input.
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
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
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
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
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
Sets the object's text x offset
object:SetTextOffsetX(xoffset[number])
Sets the object's text y offset
object:SetTextOffsetY(yoffset[number])
Sets the object's font
object:SetFont(font[font])
Gets the object's font
Returns 1 value: font [font]
local font = object:GetFont()
Sets the object's focus
object:SetFocus(focus[true])
Gets the object's focus
Returns 1 value: focus [boolean]
local focus = object:GetFocus()
Gets the object's indicator visibility
Returns 1 value: visibility [boolean]
local indicatorvisibility = object:GetIndicatorVisibility()
Sets the maximum number of characters the object's text can have
object:SetLimit(limit[number])
Sets what characters can be used in the object's text
object:SetUsable(usable[table])
Gets what characters can be used in the object's text
Returns 1 value: usable [table]
local usable = object:GetUsable()
Sets what characters can not be used in the object's text
object:SetUnusable(unusable[table])
Gets what characters can not be used in the object's text
Returns 1 value: unusable [table]
local unusable = object:GetUnsable()
Clears the object's text
object:Clear()
Sets the object's text
object:SetText(text[string])
Gets the object's text
local text = object:GetText()
Enables or disables multiline input mode
object:SetMultiline(multiline[bool])
Gets whether or not the object is using multiline input
Returns 1 value: multiline [bool]
local multiline = object:GetMultiline()
Gets the x position of the object's text
Returns 1 value: textx [number]
local textx = object:GetTextX()
Gets the y position of the object's text
Returns 1 value: texty [number]
local texty = object:GetTextY()
Gets whether or not all of the object's text is selected
Returns 1 value: alltextselected [bool]
local alltextselected = object:IsAllTextSelected()
Gets the object's line data
Returns 1 value: lines [table]
local lines = object:GetLines()
Gets object's x offset
Returns 1 value: offsetx [number]
local offsetx = object:GetOffsetX()
Gets object's y offset
Returns 1 value: offsety [number]
local offsety = object:GetOffsetY()
Gets object's indcator x position
Returns 1 value: indicatorx [number]
local indicatorx = object:GetIndicatorX()
Gets object's indcator y position
Returns 1 value: indicatory [number]
local indicatory = object:GetIndicatorY()
Toggles the line numbers panel
object:ShowLineNumbers(show_line_numbers[bool])
Sets what characters should be used to replace tab characters
object:SetTabReplacement(tabreplacement[string])
Gets object's tab replacement
Returns 1 value: tab replacement [string]
local tabreplacement = object:GetTabReplacement()
Sets whether the object is editable or not
object:SetEditable(editable[bool])
Gets whether the object is editable or not
Returns 1 value: editable [bool]
local editable = object:GetEditable()
Sets the amount that the object's scroll buttons will scroll the object's list items by
object:SetButtonScrollAmount(scrollamount[number])
Gets the object's scroll button scroll amount
Returns 1 value: scrollamount [number]
local scrollamount = object:GetButtonScrollAmount()
Sets the amount that the mouse wheel will scroll the object's list items by
object:SetMouseWheelScrollAmount(scrollamount[number])
Gets the mouse wheel's scroll amount
Returns 1 value: scroll amount [number]
local scrollamount = object:GetMouseWheelScrollAmount()
Sets whether or not the object should autoscroll when in multiline mode
object:SetAutoScroll(autoscroll[bool])
Gets whether or not the object should autoscroll when in multiline mode
Returns 1 value: autoscroll [boolean]
local autoscroll = object:GetAutoScroll()
Sets the delay before the object begins to repeat the key that is being held down
object:SetRepeatDelay(delay[number])
Gets the object's repeat delay
Returns 1 value: delay [number]
local delay = object:GetRepeatDelay()
Sets the object's value
Note: This method is an alias of SetText(text)
object:SetValue(value)
Gets the object's value
Returns 1 value: value [string]
Note: This method is an alias of GetText()
local value = object:GetValue()
These methods are used by the object internally. You should not use them unless you know what you are doing.
Called when a key is pressed and needs to be processed into text.
object:RunKey(key[string], unicode[number])
Moves the object's indicator
object:MoveIndicator(num[number], exact[boolean])
Updates the object's indicator
object:UpdateIndicator()
Adds text into the object's text at a specific location
object:AddIntoText(text[string], position[number])
Removes a chracter from the object's text
object:AddIntoText(position[number])
Gets collisions with the object's text and the mouse cursor
object:GetTextCollisions(x[number], y[number])`
Positions the object's text
object:PositionText()
Gets the object's vertical scroll body
Returns 1 value: vscrollbody [object]
local vscrollbody = object:GetVerticalScrollBody()
Gets the object's horizontal scroll body
Returns 1 value: hscrollbody [object]
local hscrollbody = object:GetHorizontalScrollBody()
Checks if the object has a vertical scroll body
Returns 1 value: hasvscrollbody [bool]
local hasvscrollbody = object:HasVerticalScrollBody()
Checks if the object has a horizontal scroll body
Returns 1 value: hashscrollbody [bool]
local hashscrollbody = object:HasHorizontalScrollBody()
Gets the object's line numbers panel
Returns 1 value: panel [object]
local panel = object:GetLineNumbersPanel()
Gets object's item width
Returns 1 value: itemwidth [number]
local itemwidth = object:GetItemWidth()
Gets object's item height
Returns 1 value: itemheight [number]
local itemheight = object:GetItemHeight()