diff --git a/src/components/LayoutGrid.vue b/src/components/LayoutGrid.vue index ea161001..e748adf1 100644 --- a/src/components/LayoutGrid.vue +++ b/src/components/LayoutGrid.vue @@ -13,6 +13,7 @@ :id="item.id" :type="item.viewType" v-bind="item.props" + @focus="onFocusView(item.id!, item.viewType!)" /> @@ -28,6 +29,13 @@ import { useViewStore } from '../store/views'; export default defineComponent({ name: 'LayoutGrid', + methods: { + onFocusView(id: string, type: string) { + if (type === '2D') { + useViewStore().setActiveViewID(id); + } + }, + }, props: { layout: { type: Object as PropType, diff --git a/src/store/views.ts b/src/store/views.ts index d4513e73..18c435a6 100644 --- a/src/store/views.ts +++ b/src/store/views.ts @@ -12,6 +12,7 @@ import { interface State { layout: Layout; viewSpecs: Record; + activeViewID: string; } export const useViewStore = defineStore('view', { @@ -21,6 +22,7 @@ export const useViewStore = defineStore('view', { items: [], }, viewSpecs: structuredClone(InitViewSpecs), + activeViewID: '', }), getters: { viewIDs(state) { @@ -28,6 +30,9 @@ export const useViewStore = defineStore('view', { }, }, actions: { + setActiveViewID(id: string) { + this.activeViewID = id; + }, addView(id: string) { if (!(id in this.viewSpecs)) { this.viewSpecs[id] = structuredClone(DefaultViewSpec);