[LoveFrames] KeyPress to click a button.
Posted: Tue Jul 28, 2015 9:38 pm
So, I'm using the loveframes library. In my game textboxes occur often so I turned displaying them into a function:
but, I want "NextTextButton" to also be 'click-able' by pressing a key on the keyboard. Anyone know of a good way to do this?
Code: Select all
function displayTextBox(inputStringArray)
currentTextPossition = 1
local textFrame = loveframes.Create("frame")
textFrame:SetName("")
textFrame:SetPos(0,476)
textFrame:SetSize(640,100)
textFrame:SetState("playing")
textFrame:ShowCloseButton(false)
textFrame:SetResizable(false)
textFrame:SetDraggable(false)
local listText = loveframes.Create("list", textFrame)
listText:SetPos(0, 0)
listText:SetSize(640, 100)
listText:SetPadding(5)
listText:SetSpacing(5)
TextBox = loveframes.Create("text")
TextBox:SetText(inputStringArray[currentTextPossition])
listText:AddItem(TextBox)
NextTextButton = loveframes.Create("button", textFrame)
NextTextButton:SetText("Next")
NextTextButton:SetPos(555,70)
NextTextButton.OnClick = function(object)
if inputStringArray[(currentTextPossition + 1)] ~= nil then
currentTextPossition = currentTextPossition + 1
TextBox:SetText(inputStringArray[currentTextPossition])
else
textFrame:Remove()
end
end
end