Skip to content

Instantly share code, notes, and snippets.

@osa1
Created March 11, 2013 12:20
Show Gist options
  • Save osa1/5133878 to your computer and use it in GitHub Desktop.
Save osa1/5133878 to your computer and use it in GitHub Desktop.
LoveFrames textinput key repeat/delay test
local filePathDialog
local filePathInput
local filePathButton
function love.load()
love.graphics.setMode(500, 500, false, false, 0)
require("LoveFrames")
filePathDialog = loveframes.Create("frame")
filePathDialog:SetName("Enter sprite file path")
filePathDialog:SetSize(400, 150)
filePathDialog:Center()
filePathDialog:SetModal(true)
filePathDialog.OnClose = function() love.event.push("quit") end
filePathInput = loveframes.Create("textinput", filePathDialog)
filePathInput:SetPos(50, 50)
filePathInput:SetWidth(200)
filePathInput:SetFocus(true)
filePathInput:SetRepeatDelay(.289)
filePathInput:SetRepeatRate(50)
print(filePathInput:GetRepeatDelay(), filePathInput:GetRepeatRate())
filePathButton = loveframes.Create("button", filePathDialog)
filePathButton:SetPos(50, 80)
filePathButton:SetWidth(100)
filePathButton:SetText("Run")
filePathButton.OnClick = function(o)
filePathDialog:Remove()
filePathInput:Remove()
filePathButton:Remove()
love.event.push("quit")
end
end
function love.update(dt)
loveframes.update(dt)
end
function love.draw()
loveframes.draw()
love.graphics.setCaption(love.timer.getFPS())
end
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
function love.keypressed(key, unicode)
if key == "escape" then love.event.push("quit") end
if key == "return" then filePathButton.OnClick() end
loveframes.keypressed(key, unicode)
end
function love.keyreleased(key)
loveframes.keyreleased(key)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment