summaryrefslogtreecommitdiff
path: root/servers/display_server.cpp
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-01-19 21:04:52 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-01-19 23:44:20 +0800
commit314f309035c9d50b41720e02550f31f89751fce0 (patch)
treeb1b75a65c452c33218cacde385514791bbe03e03 /servers/display_server.cpp
parent8b8e858778bbf9e0dad66335f351920332c547de (diff)
Add `DisplayServer.clipboard_has()` to check clipboard content
Diffstat (limited to 'servers/display_server.cpp')
-rw-r--r--servers/display_server.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index eb12b5ffc0..d4ff42bc34 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -155,6 +155,10 @@ String DisplayServer::clipboard_get() const {
ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
}
+bool DisplayServer::clipboard_has() const {
+ return !clipboard_get().is_empty();
+}
+
void DisplayServer::clipboard_set_primary(const String &p_text) {
WARN_PRINT("Primary clipboard is not supported by this display server.");
}
@@ -359,6 +363,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("clipboard_set", "clipboard"), &DisplayServer::clipboard_set);
ClassDB::bind_method(D_METHOD("clipboard_get"), &DisplayServer::clipboard_get);
+ ClassDB::bind_method(D_METHOD("clipboard_has"), &DisplayServer::clipboard_has);
ClassDB::bind_method(D_METHOD("clipboard_set_primary", "clipboard_primary"), &DisplayServer::clipboard_set_primary);
ClassDB::bind_method(D_METHOD("clipboard_get_primary"), &DisplayServer::clipboard_get_primary);