2019-03-06 23:19:58 +00:00
|
|
|
local example = {}
|
|
|
|
example.title = "Textinput"
|
|
|
|
example.category = "Object Demonstrations"
|
|
|
|
|
|
|
|
function example.func(loveframes, centerarea)
|
|
|
|
|
|
|
|
local frame = loveframes.Create("frame")
|
|
|
|
frame:SetName("Text Input")
|
|
|
|
frame:SetSize(500, 90)
|
|
|
|
frame:CenterWithinArea(unpack(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
|
2020-04-28 17:02:00 +00:00
|
|
|
textinput:SetFont(love.graphics.newFont( "resources/FreeSans-LrmZ.ttf", 12))
|
2019-03-06 23:19:58 +00:00
|
|
|
|
|
|
|
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(centerarea))
|
|
|
|
else
|
|
|
|
frame:SetHeight(365)
|
|
|
|
frame:Center()
|
|
|
|
togglebutton:SetPos(5, 335)
|
|
|
|
textinput:SetMultiline(true)
|
|
|
|
textinput:SetHeight(300)
|
|
|
|
textinput:SetText("")
|
|
|
|
frame:CenterWithinArea(unpack(centerarea))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-04-28 17:02:00 +00:00
|
|
|
return example
|