Skip to content

fix: gate anchor shortcuts to DAG context (#54) - #60

Merged
charlesangus merged 1 commit into
mainfrom
fix/issue-54-dag-shortcut-context
Jun 14, 2026
Merged

charlesangus merged 1 commit into
mainfrom
fix/issue-54-dag-shortcut-context

Conversation

@charlesangus

Copy link
Copy Markdown
Owner

Closes #54.

Problem

Anchor keyboard shortcuts were registered application-wide, so they fired regardless of which panel had focus. The most disruptive cases:

  • Ctrl+C / Ctrl+X / Ctrl+V are wrapped to copy/cut/paste hidden-input anchors, so they intercepted ordinary text editing in the Script Editor.
  • Single-key bindings like A collided with shortcuts in the Viewer and other panels.

Anchor functions are only meaningful in the Node Graph, so these shortcuts have no business firing elsewhere.

Fix

Bind every shortcut-bearing anchor command to Nuke's DAG shortcut context (shortcutContext=2) so the keys only fire when the Node Graph has focus.

  • Add a named DAG_SHORTCUT_CONTEXT constant in constants.py.
  • _add_gated_command now defaults any command that binds a shortcut to the DAG context (an explicit shortcut_context still overrides).
  • Apply the context to the top-level Copy/Cut/Paste/Input On/Off overrides and the Paste (old) fallback, which call addCommand directly.
  • Switch the existing Leader Key binding from the literal 2 to the named constant.

The leader key already used shortcutContext=2; this extends the same gating to the rest of the anchor shortcuts for consistency.

Tests

Adds tests/test_menu_shortcut_context.py, which imports menu.py against a recording nuke stub and asserts:

  • every command that binds a shortcut is DAG-gated,
  • the headline shortcuts (^C, ^X, ^V, A, +A, alt+A/J/L/Z, +M/N/B, ^M, +^D) are all present and gated,
  • commands without a shortcut carry no spurious context.

Full suite: 482 passed. README updated to document the DAG-context scoping.

Anchor functions are only meaningful in the Node Graph, but their keyboard
shortcuts fired application-wide — so Ctrl+C/X/V intercepted text editing in
the Script Editor, and single-key bindings like A collided with other panels.

Bind every shortcut-bearing anchor command to Nuke's DAG shortcut context
(shortcutContext=2) so the keys only fire when the Node Graph has focus:

- Add a named DAG_SHORTCUT_CONTEXT constant in constants.py.
- _add_gated_command now defaults any command that binds a shortcut to the
  DAG context (override still possible via shortcut_context).
- Apply the context to the top-level Copy/Cut/Paste/Input On/Off overrides and
  the Paste (old) fallback, which use addCommand directly.
- Switch the existing Leader Key binding to the named constant.

Adds tests/test_menu_shortcut_context.py, which imports menu.py against a
recording nuke stub and asserts every shortcut is DAG-gated while commands
without a shortcut carry no spurious context. Documents the gating in README.
Copilot AI review requested due to automatic review settings June 14, 2026 20:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR scopes all anchor-related keyboard shortcuts to Nuke’s DAG (Node Graph) shortcut context to prevent anchor shortcuts (notably Ctrl+C/X/V and single-key bindings like A) from firing in non-DAG panels such as the Script Editor or Viewer (closes #54).

Changes:

  • Introduces a named DAG_SHORTCUT_CONTEXT constant and applies it across shortcut registrations.
  • Updates menu.py so shortcut-bearing commands default to DAG context gating, including top-level Edit overrides and the “Paste (old)” fallback.
  • Adds a regression test to assert that all shortcut-bearing commands are DAG-gated and that non-shortcut commands don’t carry a context; README updated to document the behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
constants.py Adds DAG_SHORTCUT_CONTEXT = 2 with documentation to centralize DAG shortcut scoping.
menu.py Applies DAG shortcut gating to all anchor shortcuts and makes _add_gated_command default shortcut-bearing commands to DAG context.
tests/test_menu_shortcut_context.py New test that records addCommand calls and asserts correct shortcutContext behavior.
README.md Documents that anchor shortcuts only fire when the Node Graph has focus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@charlesangus
charlesangus merged commit 56d1b35 into main Jun 14, 2026
1 check passed
@charlesangus
charlesangus deleted the fix/issue-54-dag-shortcut-context branch June 14, 2026 20:34
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.

Shortcuts should be gated to DAG-context with shortcut_context

2 participants