prevent right click on canvas work

This commit is contained in:
Sanster 2022-04-27 17:23:01 +08:00
parent 3580d4281f
commit 390933f0eb
2 changed files with 11 additions and 2 deletions

View File

@ -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 = []

View File

@ -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
}