Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WBX-33] Add Keystrokes to Measure Mode #2033

Merged
merged 8 commits into from
Feb 16, 2024
9 changes: 9 additions & 0 deletions packages/frontend-2/components/viewer/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ import type { AutomationRun } from '~~/lib/common/generated/gql/graphql'
import { useIsSmallerOrEqualThanBreakpoint } from '~~/composables/browser'
import { useEmbed } from '~/lib/viewer/composables/setup/embed'
import { useViewerTour } from '~/lib/viewer/composables/tour'
import { onKeyStroke } from '@vueuse/core'

const { resourceItems, modelsAndVersionIds } = useInjectedViewerLoadedResources()

Expand Down Expand Up @@ -441,4 +442,12 @@ onMounted(() => {
watch(isSmallerOrEqualSm, (newVal) => {
activeControl.value = newVal ? 'none' : 'models'
})

onKeyStroke('Escape', () => {
andrewwallacespeckle marked this conversation as resolved.
Show resolved Hide resolved
if (activeControl.value === 'measurements') {
toggleMeasurements()
} else {
activeControl.value = 'none'
}
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import { MeasurementType } from '@speckle/viewer'
import { useMeasurementUtilities } from '~~/lib/viewer/composables/ui'
import { resolveComponent } from 'vue'
import type { ConcreteComponent } from 'vue'
import { onKeyStroke } from '@vueuse/core'

interface MeasurementTypeOption {
title: string
Expand Down Expand Up @@ -158,4 +159,11 @@ const measurementTypeOptions = [
description: 'Tip: Double-click to quick-measure'
}
]

onKeyStroke('Delete', () => {
removeMeasurement()
})
onKeyStroke('Backspace', () => {
removeMeasurement()
})
</script>