Difference between revisions of "love.system.setClipboardText (Français)"

(Created page with "{{newin (Français)|0.9.0|090|type=function}} Récupère le texte depuis le presse-papier. == Fonction == === Synopsis === <source lang="lua"> text = love.system.getClipbo...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{newin (Français)|[[0.9.0]]|090|type=function}}
 
{{newin (Français)|[[0.9.0]]|090|type=function}}
Récupère le texte depuis le presse-papier.
+
Place du texte dans le presse-papier.
 
== Fonction ==
 
== Fonction ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
text = love.system.getClipboardText( )
+
love.system.setClipboardText( text )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
aucun.
+
{{param|string (Français)|text|Le nouveau texte que le presse-papier du système doit contenir.}}
 
=== Retourne ===
 
=== Retourne ===
{{param|string (Français)|text (Français)|Le texte actuellement contenu dans le presse-papier du système.}}
+
Rien.
 +
== Exemples ==
 +
Règle un raccourcit clavier agnostique au système d'exploitation pour un tampon de copier-coller.
 +
<source lang="lua">
 +
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
 +
</source>
  
 
== Voir également ==
 
== Voir également ==
 
* [[parent::love.system (Français)]]
 
* [[parent::love.system (Français)]]
* [[love.system.setClipboardText (Français)]]
+
* [[love.system.getClipboardText (Français)]]
 
[[Category:Functions (Français)]]
 
[[Category:Functions (Français)]]
{{#set:Description=Récupère le texte depuis le presse-papier.}}
+
{{#set:Description=Place du texte dans le presse-papier.}}
 
== Autres langues ==
 
== Autres langues ==
{{i18n|love.system.getClipboardText}}
+
{{i18n|love.system.setClipboardText}}

Latest revision as of 12:38, 23 January 2021

Disponible depuis LÖVE 0.9.0
Ce-tte function n'est pas supporté-e par des versions plus anciennes.

Place du texte dans le presse-papier.

Fonction

Synopsis

love.system.setClipboardText( text )

Arguments

string (Français) text
Le nouveau texte que le presse-papier du système doit contenir.

Retourne

Rien.

Exemples

Règle un raccourcit clavier agnostique au système d'exploitation pour un tampon de copier-coller.

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

Voir également

Autres langues