module SF::Clipboard
Overview
Give access to the system clipboard
SF::Clipboard
provides an interface for getting and
setting the contents of the system clipboard.
It is important to note that due to limitations on some operating systems, setting the clipboard contents is only guaranteed to work if there is currently an open window for which events are being handled.
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();
// Using Ctrl + C to copy a string out of SFML
if(event.key.control && event.key.code == sf::Keyboard::C)
sf::Clipboard::setString("Hello World!");
}
}
See also: SF::String
, SF::Event
Defined in:
window/obj.crClass Method Summary
-
.string : String
Get the content of the clipboard as string data
-
.string=(text : String)
Set the content of the clipboard as string data
Class Method Detail
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
Set the content of the clipboard as string data
This function sets the content of the clipboard as a string.
WARNING Due to limitations on some operating systems, setting the clipboard contents is only guaranteed to work if there is currently an open window for which events are being handled.
- text -
SF::String
containing the data to be sent to the clipboard