diff --git a/packages/devtool-chrome/src/inject/scene/overlay/overlay.ts b/packages/devtool-chrome/src/inject/scene/overlay/overlay.ts index 305fc8c..7a50c00 100644 --- a/packages/devtool-chrome/src/inject/scene/overlay/overlay.ts +++ b/packages/devtool-chrome/src/inject/scene/overlay/overlay.ts @@ -19,6 +19,21 @@ export class Overlay { this._devtool = devtool; this._selectHighlightEnabled = devtool.state.overlayHighlightEnabled; this._pickerEnabled = devtool.state.overlayPickerEnabled; + + const handleKeyDown = (e: KeyboardEvent) => { + if (e.altKey) { + this.enablePicker(true); + } + }; + + const handleKeyUp = (e: KeyboardEvent) => { + if (!e.altKey) { + this.enablePicker(false); + } + }; + + window.addEventListener('keydown', handleKeyDown); + window.addEventListener('keyup', handleKeyUp); } public init() { diff --git a/packages/frontend/src/App.tsx b/packages/frontend/src/App.tsx index 1ce4ada..e6445ea 100644 --- a/packages/frontend/src/App.tsx +++ b/packages/frontend/src/App.tsx @@ -62,6 +62,7 @@ const App: React.FC = ({ bridge, chromeProxy }) => { const active = useDevtoolStore.use.active(); const setSelectedNode = useDevtoolStore.use.setSelectedNode(); const setActiveProps = useDevtoolStore.use.setActiveProps(); + const setOverlayPickerEnabled = useDevtoolStore.use.setOverlayPickerEnabled(); useEffect(() => { setBridge(bridge); @@ -96,11 +97,24 @@ const App: React.FC = ({ bridge, chromeProxy }) => { isDifferent(currentState.sceneGraph, data.sceneGraph) && setSceneGraph(data.sceneGraph); isDifferent(currentState.selectedNode, data.selectedNode) && setSelectedNode(data.selectedNode); isDifferent(currentState.activeProps, data.activeProps) && setActiveProps(data.activeProps); + isDifferent(currentState.overlayPickerEnabled, data.overlayPickerEnabled) && + setOverlayPickerEnabled(data.overlayPickerEnabled); } break; } }); - }, [bridge, chromeProxy, setActive, setActiveProps, setBridge, setSceneGraph, setSelectedNode, setStats, setVersion]); + }, [ + bridge, + chromeProxy, + setActive, + setActiveProps, + setBridge, + setSceneGraph, + setSelectedNode, + setStats, + setVersion, + setOverlayPickerEnabled, + ]); const windowString = `import * as PIXI from 'pixi.js'; diff --git a/packages/frontend/src/pages/scene/scene-section/Tree.tsx b/packages/frontend/src/pages/scene/scene-section/Tree.tsx index d2250f2..11e6bec 100644 --- a/packages/frontend/src/pages/scene/scene-section/Tree.tsx +++ b/packages/frontend/src/pages/scene/scene-section/Tree.tsx @@ -47,6 +47,7 @@ const Panel: React.FC = ({ children, onSearch }) => { size="icon" className="hover:border-primary h-8 rounded-none hover:border-b-2" defaultPressed={overlayPickerEnabled} + pressed={overlayPickerEnabled} onPressedChange={onPickerToggle} >