Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "author": "@Bouh, @arthuro555",
- "description": "Expression returning the content of the clipboard.",
- "extensionNamespace": "",
- "fullName": "Clipboard",
- "name": "Clipboard",
- "shortDescription": "Expression returning the content of the clipboard.",
- "tags": "clipboard, pasteboard, paste, write",
- "version": "0.0.2",
- "eventsFunctions": [
- {
- "description": "Read the text from the clipboard asynchronously (works on all platforms)",
- "fullName": "Get text from the clipboard",
- "functionType": "Action",
- "name": "readTextCrossPlaform",
- "sentence": "Read clipboard and store text in _PARAM1_",
- "events": [
- {
- "disabled": false,
- "folded": false,
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst callback =\n runtimeScene\n .getVariables()\n .get(eventsFunctionContext.getArgument(\"callback\"));\n\nif (navigator.clipboard) {\n navigator.clipboard.readText()\n .then(text => {\n callback.setString(text);\n }).catch(err => {\n console.error(\"Error occured while getting clipboard content: \", err.message);\n });\n} else if (!electron || !electron.clipboard)\n eventsFunctionContext.returnValue = electron.clipboard.readText();\n",
- "parameterObjects": "",
- "useStrict": true
- }
- ],
- "parameters": [
- {
- "codeOnly": false,
- "defaultValue": "",
- "description": "Callback variable where to store the result",
- "longDescription": "",
- "name": "callback",
- "optional": false,
- "supplementaryInformation": "",
- "type": "string"
- }
- ],
- "objectGroups": []
- },
- {
- "description": "Read the text from the clipboard (Windows, macOS, Linux only)",
- "fullName": "Get text from the clipboard (Windows, macOS, Linux)",
- "functionType": "StringExpression",
- "name": "ReadText",
- "sentence": "",
- "events": [
- {
- "disabled": false,
- "folded": false,
- "type": "BuiltinCommonInstructions::Comment",
- "color": {
- "b": 109,
- "g": 230,
- "r": 255,
- "textB": 0,
- "textG": 0,
- "textR": 0
- },
- "comment": "This is here for retrocompatibility. Try to use the asynchronous readTextCrossPlatform action instead.",
- "comment2": ""
- },
- {
- "disabled": false,
- "folded": false,
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nif (electron && electron.clipboard) eventsFunctionContext.returnValue = electron.clipboard.readText();\n",
- "parameterObjects": "",
- "useStrict": true
- }
- ],
- "parameters": [],
- "objectGroups": []
- },
- {
- "description": "Write the text in the clipboard (Windows, macOS, Linux only)",
- "fullName": "Write text to the clipboard (Windows, macOS, Linux)",
- "functionType": "Action",
- "name": "WriteText",
- "sentence": "Write _PARAM1_ to clipboard",
- "events": [
- {
- "disabled": false,
- "folded": false,
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst text = eventsFunctionContext.getArgument(\"text\");\n\nif (!electron || !electron.clipboard) {\n //TODO cache this element to not create elements on each call\n const inputElement = document.createElement(\"input\");\n inputElement.id = \"Clipboard_copy_temp\";\n inputElement.value = text;\n document.body.appendChild(inputElement);\n inputElement.select();\n inputElement.setSelectionRange(0, text.length);\n inputElement.execCommand(\"copy\");\n inputElement.remove();\n} else electron.clipboard.writeText(eventsFunctionContext.getArgument(\"text\"));\n",
- "parameterObjects": "",
- "useStrict": true
- }
- ],
- "parameters": [
- {
- "codeOnly": false,
- "defaultValue": "",
- "description": "Text to write to clipboard",
- "longDescription": "",
- "name": "text",
- "optional": false,
- "supplementaryInformation": "",
- "type": "string"
- }
- ],
- "objectGroups": []
- }
- ],
- "eventsBasedBehaviors": []
- }
Advertisement
Add Comment
Please, Sign In to add comment