diff --git a/src/components/GridLattice.vue b/src/components/GridLattice.vue index 30ec36e9..b569264f 100644 --- a/src/components/GridLattice.vue +++ b/src/components/GridLattice.vue @@ -12,7 +12,16 @@ const props = defineProps<{ labels: string[] colors: string[] heldNotes: Set + baseMidiNote:number + onTouchStart:TouchEventCallback + onTouchEnd:TouchEventCallback + onMouseDown:MouseEventCallback + onMouseUp:MouseEventCallback + onMouseEnter:MouseEventCallback + onMouseLeave:MouseEventCallback }>() +type TouchEventCallback = (event: TouchEvent, index: number) => void +type MouseEventCallback = (event: MouseEvent, index: number) => void const svgElement = ref(null) @@ -127,6 +136,13 @@ watch(() => store.modulus, computeExtent) :fill="colors[v.indices[0]] ?? 'none'" :stroke="colors[v.indices[0]] ?? 'none'" :stroke-width="store.size * 0.1" + @touchstart="onTouchStart($event, props.baseMidiNote + v.indices[0] + 1)" + @touchend="onTouchEnd($event, props.baseMidiNote + v.indices[0] + 1)" + @touchcancel="onTouchEnd($event, props.baseMidiNote + v.indices[0] + 1)" + @mousedown="onMouseDown($event, props.baseMidiNote + v.indices[0] + 1)" + @mouseup="onMouseUp($event, props.baseMidiNote + v.indices[0] + 1)" + @mouseenter="onMouseEnter($event, props.baseMidiNote + v.indices[0] + 1)" + @mouseleave="onMouseLeave($event, props.baseMidiNote + v.indices[0] + 1)" />