From 390933f0ebc84b6cc59230738f54204fe3b442ff Mon Sep 17 00:00:00 2001 From: Sanster Date: Wed, 27 Apr 2022 17:23:01 +0800 Subject: [PATCH] prevent right click on canvas work --- lama_cleaner/app/src/components/Editor/Editor.tsx | 6 +++++- lama_cleaner/app/src/utils.ts | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lama_cleaner/app/src/components/Editor/Editor.tsx b/lama_cleaner/app/src/components/Editor/Editor.tsx index 1440d78..6edffac 100644 --- a/lama_cleaner/app/src/components/Editor/Editor.tsx +++ b/lama_cleaner/app/src/components/Editor/Editor.tsx @@ -21,7 +21,7 @@ import inpaint from '../../adapters/inpainting' import Button from '../shared/Button' import Slider from './Slider' import SizeSelector from './SizeSelector' -import { downloadImage, loadImage, useImage } from '../../utils' +import { downloadImage, isRightClick, loadImage, useImage } from '../../utils' import { settingState } from '../../store/Atoms' const TOOLBAR_SIZE = 200 @@ -385,6 +385,10 @@ export default function Editor(props: EditorProps) { if (isInpaintingLoading) { return } + + if (isRightClick(ev)) { + return + } setIsDraging(true) let lineGroup: LineGroup = [] diff --git a/lama_cleaner/app/src/utils.ts b/lama_cleaner/app/src/utils.ts index 1b6b399..fc4c0e3 100644 --- a/lama_cleaner/app/src/utils.ts +++ b/lama_cleaner/app/src/utils.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { SyntheticEvent, useEffect, useState } from 'react' export function dataURItoBlob(dataURI: string) { const mime = dataURI.split(',')[0].split(':')[1].split(';')[0] @@ -182,3 +182,8 @@ export function keepGUIAlive() { }) } } + +export function isRightClick(ev: SyntheticEvent) { + const mouseEvent = ev.nativeEvent as MouseEvent + return mouseEvent.button === 2 +}