love.system.setClipboardText (简体中文)

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

设置剪贴板的文本。

函数

概要

love.system.setClipboardText( text )

参数

string text
要保存在剪贴板中的新文本。

返回值

无返回值。

例子

自定义非系统级的复制/粘贴热键(仅在游戏窗口内有效)

local buffer

function love.draw()

  love.graphics.print(
    "OS: "..love.system.getOS().."\n"..
    "Local buffer: "..tostring(buffer).."\n"..
    "System buffer: "..tostring(love.system.getClipboardText()))

end

function love.keypressed(key)

  local osString = love.system.getOS()

  local control

  if osString == "OS X" then
    control = love.keyboard.isDown("lgui","rgui")
  elseif osString == "Windows" or osString == "Linux" then
    control = love.keyboard.isDown("lctrl","rctrl")
  end

  if control then
    if key == "c" then
      if buffer then love.system.setClipboardText(buffer) end
    end
    if key == "v" then
      buffer = love.system.getClipboardText()
    end
  end

end

参考

其他语言