This commit is contained in:
Zsolt Viczian 2022-03-20 17:07:25 +01:00
parent 0ecb53e2f2
commit 24d7380333
2 changed files with 4 additions and 9 deletions

View File

@ -193,7 +193,7 @@ export const ShapesSwitcher = ({
onImageAction: (data: { pointerType: PointerType | null }) => void; onImageAction: (data: { pointerType: PointerType | null }) => void;
appState: AppState; appState: AppState;
}) => { }) => {
const deviceType = useDeviceType(); const penDetected = useDeviceType().penDetected;
return ( return (
<> <>
{SHAPES.map(({ value, icon, key }, index) => { {SHAPES.map(({ value, icon, key }, index) => {
@ -216,13 +216,12 @@ export const ShapesSwitcher = ({
aria-keyshortcuts={shortcut} aria-keyshortcuts={shortcut}
data-testid={value} data-testid={value}
onChange={({ pointerType }) => { onChange={({ pointerType }) => {
if (!deviceType.penDetected && pointerType === "pen") {
setAppState({ penMode: true });
}
setAppState({ setAppState({
elementType: value, elementType: value,
multiElement: null, multiElement: null,
selectedElementIds: {}, selectedElementIds: {},
penMode:
(!penDetected && pointerType === "pen") ?? appState.penMode,
}); });
setCursorForShape(canvas, { ...appState, elementType: value }); setCursorForShape(canvas, { ...appState, elementType: value });
if (value === "image") { if (value === "image") {

View File

@ -2867,11 +2867,7 @@ class App extends React.Component<AppProps, AppState> {
//the user can disable this by toggling the penMode button //the user can disable this by toggling the penMode button
if (!this.deviceType.penDetected && event.pointerType === "pen") { if (!this.deviceType.penDetected && event.pointerType === "pen") {
this.deviceType = updateObject(this.deviceType, { penDetected: true }); this.deviceType = updateObject(this.deviceType, { penDetected: true });
this.setState((prevState) => { this.setState({ penMode: true });
return {
penMode: true,
};
});
} }
if ( if (