[fix] penmode (#1698)

This PR fixes pen mode.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. On iPad, use the pencil to enter pen mode
2. Select the draw tool
3. touch the screen

- [x] Unit Tests (sort of)

### Release Notes

- [fix] pen mode
This commit is contained in:
Steve Ruiz 2023-07-04 11:11:57 +01:00 committed by GitHub
parent 2aa6c4cbe3
commit 603966486d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -9205,7 +9205,11 @@ export class Editor extends EventEmitter<TLEventMap> {
inputs.isPointing = true inputs.isPointing = true
inputs.isDragging = false inputs.isDragging = false
if (!this.isPenMode) { if (this.isPenMode) {
if (!isPen) {
return
}
} else {
if (isPen) { if (isPen) {
this.setPenMode(true) this.setPenMode(true)
} }

View file

@ -0,0 +1,27 @@
import { Vec2d } from '@tldraw/primitives'
import { TestEditor } from './TestEditor'
let editor: TestEditor
beforeEach(() => {
editor = new TestEditor()
})
it('ignores touch events while in pen mode', async () => {
editor.setSelectedTool('draw')
editor.setPenMode(true)
editor.dispatch({
type: 'pointer',
name: 'pointer_down',
isPen: false,
pointerId: 1,
point: new Vec2d(100, 100),
shiftKey: false,
altKey: false,
ctrlKey: false,
button: 1,
target: 'canvas',
})
expect(editor.shapesArray.length).toBe(0)
})