feat: support setting/resetting cursor from host (#5215)

* Support setting/resetting cursor type from host

* add docs

* minor
This commit is contained in:
Aakansha Doshi 2022-05-20 18:43:38 +05:30 committed by GitHub
parent 92f30f7ed6
commit 07ebd7c68c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 7 deletions

View file

@ -383,6 +383,8 @@ class App extends React.Component<AppProps, AppState> {
setToastMessage: this.setToastMessage,
id: this.id,
setActiveTool: this.setActiveTool,
setCursor: this.setCursor,
resetCursor: this.resetCursor,
} as const;
if (typeof excalidrawRef === "function") {
excalidrawRef(api);
@ -1921,6 +1923,13 @@ class App extends React.Component<AppProps, AppState> {
}
};
private setCursor = (cursor: string) => {
setCursor(this.canvas, cursor);
};
private resetCursor = () => {
resetCursor(this.canvas);
};
/**
* returns whether user is making a gesture with >= 2 fingers (points)
* on o touch screen (not on a trackpad). Currently only relates to Darwin
@ -3013,7 +3022,7 @@ class App extends React.Component<AppProps, AppState> {
pointerDownState,
);
} else if (this.state.activeTool.type === "custom") {
setCursor(this.canvas, CURSOR_TYPE.CROSSHAIR);
setCursor(this.canvas, CURSOR_TYPE.AUTO);
} else if (this.state.activeTool.type !== "eraser") {
this.createGenericElementOnPointerDown(
this.state.activeTool.type,