Skip to content

F-key scenes can be stored but not recalled (scene/view fallback missing from key dispatch) #260

Description

@javierbq

Summary

RayMol#258 wired up cmd.set_key dispatch, which made PyMOL's 125 built-in default bindings live for the first time. That surfaced an asymmetry in the F-key scene workflow: you can store a scene to an F-key but not recall it.

  • CTRL-F1CTRL-F12scene F1, storescene F12, store are real entries in modules/pymol/shortcut_dict.py (lines 112–137), so storing works.
  • Bare F1F12 are not in the defaults. In upstream PyMOL, recall works anyway because _special falls through: it tries _invoke_key first, and if no binding exists it looks the key up against the scene list and the view dict.

RayMol's bridge calls pymol.internal._invoke_key(token) directly (PyMOLBridge_InvokeKey in PyMOLBridge.mm), deliberately bypassing _special — because PyMOL_Special also grabs arrows for the core's hidden Ortho prompt, which RayMol doesn't use. The side effect is that the scene/view fallback is skipped too.

Impact

A user presses ⌃F1 to store a scene, then presses F1 to get it back and nothing happens. Storing silently succeeds; recall silently does nothing. Scenes are still reachable via the Scene panel and the scene F1 command, so this is a parity gap rather than data loss.

Not a regression — before #258 neither half worked.

Proposed fix

Add an invoke(token) helper to modules/pymol/raymol_keys.py that mirrors _special's fallthrough without touching upstream files:

  1. internal._invoke_key(token, 1) — if it fires, return true.
  2. Otherwise, for special-key names only, try the scene list then the view dict, using the same Shortcut-based prefix interpretation _special uses.
  3. Return whether anything fired.

Then point PyMOLBridge_InvokeKey at that helper instead of _invoke_key. The consume-iff-fired contract the monitor depends on is preserved: a successful scene recall counts as fired.

Keep it out of the arrow path — left/right are bound to movie frames by default, so they never reach a fallback anyway, and we do not want to reintroduce Ortho's arrow-grabbing behavior.

Verification

  • Pure-Python test in testing/tests/test_raymol_keys.py: with a fake cmd exposing a scene list, assert invoke('F1') recalls the scene and returns true; assert an unknown token returns false.
  • Manual: ⌃F1 to store, orbit away, F1 to recall.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions