11<script lang="ts" setup>
22import type { Elements } from ' @vue-flow/core'
3- import { VueFlow , isNode , useVueFlow } from ' @vue-flow/core'
3+ import { Panel , PanelPosition , VueFlow , isNode , useVueFlow } from ' @vue-flow/core'
44
55import { Background } from ' @vue-flow/background'
66import { Controls } from ' @vue-flow/controls'
@@ -15,13 +15,19 @@ const elements = ref<Elements>([
1515 { id: ' e1-3' , source: ' 1' , target: ' 3' },
1616])
1717
18- const { onConnect, addEdges, setTransform, toObject } = useVueFlow ({
18+ const keyCode = ref (' Shift' )
19+
20+ const { selectionKeyCode, onConnect, addEdges, setTransform, toObject } = useVueFlow ({
1921 minZoom: 0.2 ,
2022 maxZoom: 4 ,
2123})
2224
2325onConnect ((params ) => addEdges ([params ]))
2426
27+ function changeKeyCode() {
28+ keyCode .value = keyCode .value === ' Shift' ? ' Meta' : ' Shift'
29+ }
30+
2531function updatePos() {
2632 return elements .value .forEach ((el ) => {
2733 if (isNode (el )) {
@@ -45,15 +51,16 @@ function toggleclass() {
4551 </script >
4652
4753<template >
48- <VueFlow v-model =" elements" fit-view-on-init class =" vue-flow-basic-example" >
54+ <VueFlow v-model =" elements" :selection-key-code = " keyCode " fit-view-on-init class =" vue-flow-basic-example" >
4955 <Background />
5056 <MiniMap />
5157 <Controls />
52- <div style =" position : absolute ; right : 10px ; top : 10px ; z-index : 4 " >
53- <button style =" margin-right : 5px " @click =" resetTransform" >reset transform</button >
54- <button style =" margin-right : 5px " @click =" updatePos" >change pos</button >
55- <button style =" margin-right : 5px " @click =" toggleclass" >toggle class</button >
58+ <Panel :position =" PanelPosition.TopRight" style =" display : flex ; gap : 5px " >
59+ {{ selectionKeyCode }}
60+ <button @click =" changeKeyCode" >change keyCode</button >
61+ <button @click =" updatePos" >change pos</button >
62+ <button @click =" toggleclass" >toggle class</button >
5663 <button @click =" logToObject" >toObject</button >
57- </div >
64+ </Panel >
5865 </VueFlow >
5966</template >
0 commit comments