love.system.setClipboardText

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

Puts text in the clipboard.

Function

Synopsis

love.system.setClipboardText( text )

Arguments

string text
The new text to hold in the system's clipboard.

Returns

Nothing.

Examples

Set up OS agnostic keybindings for a copy paste buffer.

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

See Also

© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.system.setClipboardText