From f693c588c5d28f0fa3b898bcaece3ed3d0889a88 Mon Sep 17 00:00:00 2001 From: Jeffrey Lanters Date: Fri, 6 Jan 2023 15:51:46 +0100 Subject: [PATCH] Added disabled canvas events api to documentation --- .../docs/api/disabled-canvas-events.md | 38 +++++++++++++++++++ documentation/sidebars.json | 4 ++ 2 files changed, 42 insertions(+) create mode 100644 documentation/docs/api/disabled-canvas-events.md diff --git a/documentation/docs/api/disabled-canvas-events.md b/documentation/docs/api/disabled-canvas-events.md new file mode 100644 index 0000000..0233a52 --- /dev/null +++ b/documentation/docs/api/disabled-canvas-events.md @@ -0,0 +1,38 @@ +# Disabled Canvas Events + +Overwrites the default disabled canvas events. + +## Type Definition + +```tsx title="Type Definition" + +``` + +## Implementation + +> By default Unity disables the `contextmenu` and `dragstart` events on the canvas element. This is done to prevent the user from right clicking on the canvas and dragging the page while interacting with the Unity Application. Note that by setting the `disabledCanvasEvents` property you'll override the default values. If you don't want this to happen, you'll need to add events these to the array. + +## Example Usage​ + +A basic implementation could look something like this. In the following example overwrite the default values and disable the `dragstart` and `scroll` events. This will also allow the user to right click on the canvas to open the context menu. + +```jsx {10-21} showLineNumbers title="App.jsx" +import React from "react"; +import { Unity, useUnityContext } from "react-unity-webgl"; + +function App() { + const { unityProvider } = useUnityContext({ + loaderUrl: "build/myunityapp.loader.js", + dataUrl: "build/myunityapp.data", + frameworkUrl: "build/myunityapp.framework.js", + codeUrl: "build/myunityapp.wasm", + }); + + return ( + + ); +} +``` diff --git a/documentation/sidebars.json b/documentation/sidebars.json index b398b1e..ff6dd8e 100644 --- a/documentation/sidebars.json +++ b/documentation/sidebars.json @@ -169,6 +169,10 @@ "type": "doc", "id": "api/webgl-rendering-context" }, + { + "type": "doc", + "id": "api/disabled-canvas-events" + }, { "type": "doc", "id": "api/meta-data"