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

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

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
}
}
}
// set the clipboard to a string
gf::Clipboard::setString("Hello World!");
static std::string getString()
Get the content of the clipboard as string data.
static void setString(const std::string &text)
Set the content of the clipboard as string data.
constexpr bool test(E flag) const
Test if a specified flag is set.
Definition: Flags.h:150
@ Control
Is the Control key pressed?
@ Closed
The window requested to be closed (data in event.window)
@ KeyPressed
A key was pressed (data in event.key)
Defines a system event and its parameters.
Definition: Event.h:224
EventType type
Type of the event.
Definition: Event.h:225
KeyEvent key
Key event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated)
Definition: Event.h:231
Flags< Mod > modifiers
Modifiers that are pressed.
Definition: Event.h:111
Keycode keycode
Keycode of the key.
Definition: Event.h:109

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