Gamedev Framework (gf)  0.9.0
A C++14 framework for 2D games
Static Public Member Functions | List of all members
gf::Clipboard Class Reference

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

#include <gf/Clipboard.h>

Static Public Member Functions

static std::string getString ()
 Get the content of the clipboard as string data. More...
 
static void setString (const std::string &text)
 Set the content of the clipboard as string data. More...
 

Detailed Description

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

Usage example:

// get the clipboard content as a string
std::string string = gf::Clipboard::getString();
// or use it in the event loop
gf::Event event;
while (window.pollEvent(event)) {
if(event.type == gf::EventType::Closed) {
window.close();
}
// Using Ctrl + V to paste a string
if (event.key.modifiers.test(gf::Mod::Control) && event.key.keycode == gf::Keycode::V) {
}
}
}
// set the clipboard to a string
gf::Clipboard::setString("Hello World!");

Member Function Documentation

◆ getString()

static std::string gf::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 string.

Returns
The clipboard contents

◆ setString()

static void gf::Clipboard::setString ( const std::string &  text)
static

Set the content of the clipboard as string data.

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

Parameters
textA string containing the data to be sent to the clipboard