Page 1 of 1
Mousepressed and Keypressed=> TextInput
Posted: Sat Apr 19, 2014 6:24 am
by TheScriptan
Hello everyone! So I followed some tutorials where there was a function Mousepressed, but this function I think is deleted and it's not mentioned in the wiki!:)
I am new to Love2D and I saw one change here: KeyPressed to textinput. So I can't get the input work with textinput, maybe some of you could give me a simple example of user input using textinput function?
Re: Mousepressed and Keypressed=> TextInput
Posted: Sat Apr 19, 2014 9:09 am
by SneakySnake
TheScriptan wrote:So I followed some tutorials where there was a function Mousepressed, but this function I think is deleted and it's not mentioned in the wiki!:)
It wasn't deleted. It still exists.
TheScriptan wrote:I am new to Love2D and I saw one change here: KeyPressed to textinput.
textinput is not a replacement of keypressed. keypressed still exists.
LÖVE 0.9.1 code
Code: Select all
local log = {}
function love.load()
love.keyboard.setKeyRepeat(true)
end
function love.mousepressed(x, y, button)
table.insert(log, string.format("Mouse button %s pressed at %s, %s", button, x, y))
end
function love.keypressed(key, isrepeat)
local r = isrepeat and "It's a repeat" or "Not a repeat"
table.insert(log, string.format("Key %s pressed, %s", key, r))
end
function love.draw()
for i, v in ipairs(log) do
love.graphics.print(v, 0, (i - 1) * love.graphics.getFont():getHeight())
end
end
Re: Mousepressed and Keypressed=> TextInput
Posted: Sat Apr 19, 2014 9:34 am
by TheScriptan
EDIT:
Sorry, I didn't notice that there is a variable in keypressed function that is required! Thank you for the information!