mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: support setting/resetting cursor from host (#5215)
* Support setting/resetting cursor type from host * add docs * minor
This commit is contained in:
parent
92f30f7ed6
commit
07ebd7c68c
6 changed files with 63 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue