{
  "name": "Clipboard",
  "component": "gui",
  "header": "nativeui/clipboard.h",
  "type": "Object",
  "namespace": "nu",
  "description": "Native clipboard.",
  "detail": "The `Clipboard` class can not be created by user, its instance can only be\nrecevied by using the factory methods.\n\n```cpp\n// Get the default copy-paste clipboard.\nnu::Clipboard* clipboard = nu::Clipboard::Get();\n\n// Changing the content of clipboard with multiple formats of data.\nstd::vector<nu::Clipboard::Data> objects;\n// Add text.\nobjects.emplace_back(nu::Clipboard::Text, \"some text\");\n// Add HTML.\nobjects.emplace_back(nu::Clipboard::HTML, \"<strong>some text</strong>\");\n// Add Image.\nobjects.emplace_back(new nu::Image(\"...\"));\n// Add file paths.\nobjects.emplace_back({\n  base::FilePath(FILE_PATH_LITERAL(\"/some/path\")),\n});\n// Change data.\nclipboard->SetData(std::move(objects));\n\n// Read data.\nData data = clipboard->GetData(nu::Clipboard::Data::Type::Text);\nif (data.type() == nu::Clipboard::Data::Type::Text)\n  LOG(INFO) << data.str();\n```\n\n```lua\n-- Get the default copy-paste clipboard.\nlocal clipboard = gui.Clipboard.get()\n\n-- Changing the content of clipboard with multiple formats of data.\nclipboard:setdata{\n  {type='text', value='some text'},\n  {type='html', value='<strong>some text</strong>'},\n  {type='image', value=gui.Image.createfrompath('...')},\n  {type='file-paths', value={'/some/path'}},\n}\n\n-- Read data.\nlocal data = clipboard:getdata('text')\nif data.type == 'text' then\n  print(data.value)\nend\n```\n\n```js\n// Get the default copy-paste clipboard.\nconst clipboard = gui.Clipboard.get()\n\n// Changing the content of clipboard with multiple formats of data.\nclipboard.setData([\n  {type: 'text', value: 'some text'},\n  {type: 'html', value: '<strong>some text</strong>'},\n  {type: 'image', value: gui.Image.createFromPath('...')},\n  {type: 'file-paths', value: ['/some/path']},\n])\n\n// Read data.\nconst data = clipboard.getData('text')\nif (data.type == 'text')\n  console.log(data.value)\n```\n",
  "class_methods": [
    {
      "signature": {
        "returnType": {
          "name": "Clipboard",
          "id": "clipboard"
        },
        "name": "get",
        "parameters": [],
        "shortStr": "get()",
        "str": "get()"
      },
      "description": "Return the default copy-paste clipboard.",
      "id": "get"
    },
    {
      "signature": {
        "returnType": {
          "name": "Clipboard",
          "id": "clipboard"
        },
        "name": "fromType",
        "parameters": [
          {
            "type": {
              "name": "Clipboard::Type",
              "id": "clipboard_type"
            },
            "name": "type"
          }
        ],
        "shortStr": "fromType(type)",
        "str": "fromType(type)"
      },
      "description": "Return the clipboard with `type`.",
      "id": "fromtype-type"
    }
  ],
  "methods": [
    {
      "signature": {
        "name": "clear",
        "parameters": [],
        "shortStr": "clear()",
        "str": "clear()"
      },
      "description": "Clear the clipboard.",
      "id": "clear"
    },
    {
      "signature": {
        "name": "setText",
        "parameters": [
          {
            "type": {
              "name": "String"
            },
            "name": "text"
          }
        ],
        "shortStr": "setText(text)",
        "str": "setText(text)"
      },
      "description": "Set `text` as clipboard's content.",
      "id": "settext-text"
    },
    {
      "signature": {
        "returnType": {
          "name": "String"
        },
        "name": "getText",
        "parameters": [],
        "shortStr": "getText()",
        "str": "getText()"
      },
      "description": "Return the content of clipboard as text.",
      "id": "gettext"
    },
    {
      "signature": {
        "returnType": {
          "name": "Boolean"
        },
        "name": "isDataAvailable",
        "parameters": [
          {
            "type": {
              "name": "Clipboard::Data::Type",
              "id": "clipboard_data_type"
            },
            "name": "type"
          }
        ],
        "shortStr": "isDataAvailable(type)",
        "str": "isDataAvailable(type)"
      },
      "description": "Return whether the data of `type` is available.",
      "id": "isdataavailable-type"
    },
    {
      "signature": {
        "returnType": {
          "name": "Clipboard::Data",
          "id": "clipboard_data"
        },
        "name": "getData",
        "parameters": [
          {
            "type": {
              "name": "Clipboard::Data::Type",
              "id": "clipboard_data_type"
            },
            "name": "type"
          }
        ],
        "shortStr": "getData(type)",
        "str": "getData(type)"
      },
      "description": "Get the data of `type` from clipboard.",
      "detail": "You should always check the type of returned data before using it.",
      "id": "getdata-type"
    },
    {
      "signature": {
        "name": "setData",
        "parameters": [
          {
            "type": {
              "name": "Array",
              "elementType": {
                "name": "Clipboard::Data",
                "id": "clipboard_data"
              }
            },
            "name": "objects",
            "description": "An array of `<!type>Clipboard::Data`."
          }
        ],
        "shortStr": "setData(objects)",
        "str": "setData(objects)"
      },
      "description": "Set clipboard's content.",
      "id": "setdata-objects"
    },
    {
      "signature": {
        "name": "startWatching",
        "parameters": [],
        "shortStr": "startWatching()",
        "str": "startWatching()"
      },
      "description": "Start watching clipboard's content.",
      "detail": "The `<!name>on_change` event will be emitted when clipboard's content has\nbeen changed.\n\nOn macOS, due to lack of system notifications for clipboard events, this\nevent is implemented by polling every 500ms.\n",
      "id": "startwatching"
    },
    {
      "signature": {
        "name": "stopWatching",
        "parameters": [],
        "shortStr": "stopWatching()",
        "str": "stopWatching()"
      },
      "description": "Stop watching clipboard's content.",
      "id": "stopwatching"
    }
  ],
  "events": [
    {
      "signature": {
        "name": "onChange",
        "parameters": [
          {
            "type": {
              "name": "Clipboard",
              "id": "clipboard"
            },
            "name": "self"
          }
        ],
        "shortStr": "onChange(self)",
        "str": "onChange(self)"
      },
      "description": "Emitted when clipboard's content has been changed.",
      "detail": "The `<!name>StartWatching` method must be called first to make this event\nwork.\n",
      "id": "onchange-self"
    }
  ],
  "module": "gui",
  "id": "clipboard"
}