テキスト入力イベントの有効・無効の取得

love.keyboard.hasTextInput

追加バージョン0.9.0削除バージョン-

テキスト入力イベントの有効・無効を取得します。

local inputText = ""

function love.load()
  love.keyboard.setTextInput(true)
end

function love.draw()
  love.graphics.print(tostring(love.keyboard.hasTextInput()), 20, 20)
  love.graphics.print(inputText, 20, 40)
end

function love.textinput(text)
  inputText = inputText .. text
end

function love.mousepressed(x, y, button, istouch)
  love.keyboard.setTextInput(not(love.keyboard.hasTextInput()))
end
テキスト入力イベントの有効・無効の取得

マウスをクリックするたびにテキスト入力の有効・無効が切り替わり、trueまたはfalseで表示されます。有効のときには入力した文字が画面に表示されます。