You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"shortDescription": "Read and write the clipboard.",
12
-
"version": "1.0.0",
11
+
"version": "2.0.0",
12
+
"description": "This extension allows to access the clipboard.",
13
+
"origin": {
14
+
"identifier": "Clipboard",
15
+
"name": "gdevelop-extension-store"
16
+
},
13
17
"tags": [
14
18
"clipboard",
15
19
"pasteboard",
@@ -31,33 +35,69 @@
31
35
],
32
36
"eventsFunctions": [
33
37
{
34
-
"description": "Read the text from the clipboard asynchronously. As this is \"asynchronous\", this means that the variable won't be immediately filled with the text from the clipboard. Instead, it will be filled a few milliseconds later.\n\nNote also that on web browsers, the user might be asked for permissions to read from the clipboard.",
38
+
"async": true,
39
+
"description": "Read the text from the clipboard asynchronously. \n\nNote also that on web browsers, the user might be asked for permissions to read from the clipboard.",
35
40
"fullName": "Get text from the clipboard",
36
41
"functionType": "Action",
37
-
"name": "ReadTextCrossPlaform",
38
-
"private": false,
42
+
"name": "AsynchronouslyReadTextCrossPlaform",
39
43
"sentence": "Read clipboard and store text in _PARAM1_",
40
44
"events": [
41
45
{
42
-
"disabled": false,
43
-
"folded": false,
44
46
"type": "BuiltinCommonInstructions::JsCode",
45
-
"inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst callback =\n runtimeScene\n .getVariables()\n .get(eventsFunctionContext.getArgument(\"callback\"));\n\nif (electron !== null && electron.clipboard)\n callback.setString(electron.clipboard.readText());\nelse if (\n typeof cordova !== \"undefined\" &&\n cordova.plugins &&\n cordova.plugins.clipboard\n) cordova.plugins.clipboard.paste(text => callback.setString(text));\nelse if (\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n navigator.clipboard.readText\n) {\n navigator.clipboard.readText()\n .then(text => callback.setString(text))\n .catch(err =>\n console.error(\"Error occured while getting clipboard content: \", err.message)\n );\n} else console.error(\"Unable to read from the clipboard: no method found for this platform.\")\n",
47
+
"inlineCode": [
48
+
"const electron = runtimeScene.getGame().getRenderer().getElectron();",
" logger.error(\"An error occured while getting clipboard content: \", error);",
68
+
" task.resolve();",
69
+
" }",
70
+
" );",
71
+
"} else if (",
72
+
" typeof navigator !== \"undefined\" &&",
73
+
" navigator.clipboard &&",
74
+
" navigator.clipboard.readText",
75
+
") {",
76
+
" navigator.clipboard.readText()",
77
+
" .then(text => {",
78
+
" callback.setString(text);",
79
+
" task.resolve();",
80
+
" })",
81
+
" .catch(error => {",
82
+
" logger.error(\"An error occured while getting clipboard content: \", error.message);",
83
+
" task.resolve();",
84
+
" });",
85
+
"} else {",
86
+
" logger.error(\"Unable to read from the clipboard: no method found for this platform.\");",
87
+
" task.resolve();",
88
+
"}",
89
+
""
90
+
],
46
91
"parameterObjects": "",
47
92
"useStrict": true,
48
93
"eventsSheetExpanded": false
49
94
}
50
95
],
51
96
"parameters": [
52
97
{
53
-
"codeOnly": false,
54
-
"defaultValue": "",
55
-
"description": "Callback variable where to store the result",
56
-
"longDescription": "",
98
+
"description": "Callback variable where to store the clipboard contents",
57
99
"name": "callback",
58
-
"optional": false,
59
-
"supplementaryInformation": "",
60
-
"type": "string"
100
+
"type": "scenevar"
61
101
}
62
102
],
63
103
"objectGroups": []
@@ -67,44 +107,105 @@
67
107
"fullName": "Write text to the clipboard",
68
108
"functionType": "Action",
69
109
"name": "WriteText",
70
-
"private": false,
71
110
"sentence": "Write _PARAM1_ to clipboard",
72
111
"events": [
73
112
{
74
-
"disabled": false,
75
-
"folded": false,
76
113
"type": "BuiltinCommonInstructions::JsCode",
77
-
"inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst text = eventsFunctionContext.getArgument(\"text\");\n\nif (electron !== null && electron.clipboard)\n electron.clipboard.writeText(text);\nelse if (\n typeof cordova !== \"undefined\" &&\n cordova.plugins &&\n cordova.plugins.clipboard\n) cordova.plugins.clipboard.copy(text);\nelse if (\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n navigator.clipboard.writeText\n) navigator.clipboard\n .writeText(text)\n .catch(e => console.error(\"Error while writing clipboard: \", e));\nelse console.error(\"Unable to write to the clipboard: no method found for this platform.\"); \n",
114
+
"inlineCode": [
115
+
"const electron = runtimeScene.getGame().getRenderer().getElectron();",
116
+
"const text = eventsFunctionContext.getArgument(\"text\");",
117
+
"",
118
+
"if (electron !== null && electron.clipboard)",
119
+
" electron.clipboard.writeText(text);",
120
+
"else if (",
121
+
" typeof cordova !== \"undefined\" &&",
122
+
" cordova.plugins &&",
123
+
" cordova.plugins.clipboard",
124
+
") cordova.plugins.clipboard.copy(text);",
125
+
"else if (",
126
+
" typeof navigator !== \"undefined\" &&",
127
+
" navigator.clipboard &&",
128
+
" navigator.clipboard.writeText",
129
+
") navigator.clipboard",
130
+
" .writeText(text)",
131
+
" .catch(e => console.error(\"Error while writing clipboard: \", e));",
132
+
"else console.error(\"Unable to write to the clipboard: no method found for this platform.\"); ",
133
+
""
134
+
],
78
135
"parameterObjects": "",
79
136
"useStrict": true,
80
137
"eventsSheetExpanded": false
81
138
}
82
139
],
83
140
"parameters": [
84
141
{
85
-
"codeOnly": false,
86
-
"defaultValue": "",
87
142
"description": "Text to write to clipboard",
88
-
"longDescription": "",
89
143
"name": "text",
90
-
"optional": false,
91
-
"supplementaryInformation": "",
92
144
"type": "string"
93
145
}
94
146
],
95
147
"objectGroups": []
96
148
},
97
149
{
98
-
"description": "Read the text from the clipboard (Windows, macOS, Linux only)",
99
-
"fullName": "Get text from the clipboard (Windows, macOS, Linux)",
150
+
"description": "Read the text from the clipboard asynchronously. As this is \"asynchronous\", the variable won't be immediately filled with the text from the clipboard. You will have to wait a few frames before it will be. If you want your subsequent actions and subevents to automatically wait for the read to finish, use the waiting version of this action instead (recomended). \n\nNote also that on web browsers, the user might be asked for permissions to read from the clipboard.",
151
+
"fullName": "(No waiting) Get text from the clipboard",
152
+
"functionType": "Action",
153
+
"name": "ReadTextCrossPlaform",
154
+
"private": true,
155
+
"sentence": "Read clipboard and store text in _PARAM1_",
156
+
"events": [
157
+
{
158
+
"type": "BuiltinCommonInstructions::JsCode",
159
+
"inlineCode": [
160
+
"const electron = runtimeScene.getGame().getRenderer().getElectron();",
0 commit comments