Skip to content

Allow using the scene editor shortcuts without clicking on the canvas first - #8938

Open
Bouh wants to merge 3 commits into
masterfrom
instances-editor-space-pan-without-focus
Open

Allow using the scene editor shortcuts without clicking on the canvas first#8938
Bouh wants to merge 3 commits into
masterfrom
instances-editor-space-pan-without-focus

Conversation

@Bouh

@Bouh Bouh commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

This PR allows using space bar panning without having to focus the canvas.
It removes a currently mandatory focus click. This is much more consistent with mouse wheel zoom, which doesn't need focus to work.
Moreover, it makes the workflow smoother and more pleasant.

Tested on web with the 2D and 3D views in editor.

Claude Code said:

Problem

In the scene editor, the mouse wheel zoom works as soon as the canvas is hovered, but the keyboard shortcuts (notably space to move the view) require clicking on the canvas first. Clicking in any panel, for example the objects list, is enough to lose them.

Two different causes, one per editor:

  • 2D canvas: keydown/keyup were listened on the canvas itself, which has tabIndex = -1, so the events only arrived when it was focused.
  • In-game editor: the game runs in an <iframe>, a separate document that only receives keyboard events when it has the focus.

Changes

Instances editor (InstancesEditor/index.js): the shortcuts are listened on the window and restricted to this editor by the isActive option of KeyboardShortcuts, which is true when the canvas is hovered or focused. The capture phase is used so that a focused component stopping the event propagation (the tree views handle the keyboard) can't prevent them from working. Key releases are always handled, so that releasing a key after leaving the canvas (which happens when moving the view up to its border) doesn't leave it considered as pressed, and the modifiers are reset when the window is blurred (Alt+Tab with a key held down).

In-game editor (EmbeddedGameFrame.js): the iframe is given the focus as soon as it is hovered, with the same call that is already made when a preview is attached. The listener is on the iframe itself, so the overlay covering it (drop target, pointer events blocker) never triggers it.

The focus is not taken when a text is being edited (renaming an object, editing a property...) nor when a dialog is opened, to avoid interrupting the user or fighting with a focus trap. Nothing changes for touch devices: only KeyboardEvents are involved, the pinch and touch gestures go through their own handlers.

Testing

  • Click in the objects list, hover the 2D canvas, then use space + drag to move the view, and the arrow keys / Delete / Ctrl+C on the selection.
  • Same with the in-game editor (2D and 3D).
  • Check that renaming an object while the cursor sits over the canvas still types normally, and that a dialog opened over the game keeps its keyboard navigation.

Bouh added 3 commits August 9, 2026 14:59
Keyboard shortcuts were listened on the canvas itself, which required
clicking on it to give it focus. Listen on the window instead, and handle
the shortcuts when the canvas is either hovered or focused, so that the
space key can be used to move the view right away (like the mouse wheel
zoom already did).
…ts handling

The in-game editor runs in an iframe, which is a separate document only
receiving keyboard events when focused: give it the focus as soon as it is
hovered, so that its shortcuts (notably space to move the view) can be used
without clicking on the game first.

In the instances editor, reuse the `isActive` option of KeyboardShortcuts
instead of filtering the events in wrappers, and always handle key releases
so that releasing a key after leaving the canvas (which happens when moving
the view up to its border) doesn't leave it considered as pressed.
@Bouh
Bouh requested a review from 4ian as a code owner August 9, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant