SFML - Simple and Fast Multimedia Library

SFML 2.5.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Member Functions | List of all members
sf::Clipboard Class Reference
Window module

Give access to the system clipboard. More...

`#include <Clipboard.hpp>`

## Static Public Member Functions
static String | getString ()
| Get the content of the clipboard as string data. More...
static void | setString (const String &text)
| Set the content of the clipboard as string data. More...

## Detailed Description

Give access to the system clipboard.

sf::Clipboard provides an interface for getting and setting the contents of the system clipboard.

Usage example:

// get the clipboard content as a string
sf::String string = sf::Clipboard::getString();
// or use it in the event loop
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(event.type == sf::Event::KeyPressed)
{
// Using Ctrl + V to paste a string into SFML
if(event.key.control && event.key.code == sf::Keyboard::V)
string = sf::Clipboard::getString();
}
}
// set the clipboard to a string
sf::Clipboard::setString("Hello World!");

See also
  sf::String, sf::Event

Definition at line 41 of file Clipboard.hpp.

## Member Function Documentation

## ◆ getString()

static String sf::Clipboard::getString | ( |  | ) |
| static

Get the content of the clipboard as string data.

This function returns the content of the clipboard as a string. If the clipboard does not contain string it returns an empty sf::String object.

Returns
  Clipboard contents as sf::String object

## ◆ setString()

static void sf::Clipboard::setString | ( | const String & | text | ) |
| static

Set the content of the clipboard as string data.

This function sets the content of the clipboard as a string.

Parameters

  text | sf::String containing the data to be sent to the clipboard

The documentation for this class was generated from the following file:

- Clipboard.hpp