Skip to content

Commit

Permalink
[WBX-33] Add Keystrokes to Measure Mode (#2033)
Browse files Browse the repository at this point in the history
* Add onKeyStroke Escape to Controls

* Add onKeyStroke Delete/Backspace on active measurement

* Updates

* Update

* Move keystrokes

* Turn off measurements on esc
  • Loading branch information
andrewwallacespeckle authored Feb 16, 2024
1 parent 90a930b commit 0b9a6ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 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,8 @@ onMounted(() => {
watch(isSmallerOrEqualSm, (newVal) => {
activeControl.value = newVal ? 'none' : 'models'
})
onKeyStroke('Escape', () => {
activeControl.value = 'none'
})
</script>
15 changes: 13 additions & 2 deletions packages/frontend-2/lib/viewer/composables/setup/postSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { Vector3 } from 'three'
import { areVectorsLooselyEqual } from '~~/lib/viewer/helpers/three'
import type { Nullable } from '@speckle/shared'
import { useCameraUtilities } from '~~/lib/viewer/composables/ui'
import { watchTriggerable } from '@vueuse/core'
import { onKeyStroke, watchTriggerable } from '@vueuse/core'
import { setupDebugMode } from '~~/lib/viewer/composables/setup/dev'
import { CameraController } from '@speckle/viewer'
import type { Reference } from '@apollo/client'
Expand Down Expand Up @@ -725,7 +725,8 @@ function useViewerMeasurementIntegration() {
viewer: { instance }
} = useInjectedViewerState()

const { clearMeasurements } = useMeasurementUtilities()
const { clearMeasurements, removeMeasurement, enableMeasurements } =
useMeasurementUtilities()

onBeforeUnmount(() => {
clearMeasurements()
Expand All @@ -750,6 +751,16 @@ function useViewerMeasurementIntegration() {
},
{ immediate: true, deep: true }
)

onKeyStroke('Delete', () => {
removeMeasurement()
})
onKeyStroke('Backspace', () => {
removeMeasurement()
})
onKeyStroke('Escape', () => {
enableMeasurements(false)
})
}

function useDisableZoomOnEmbed() {
Expand Down

0 comments on commit 0b9a6ae

Please sign in to comment.