From 85e90088d5d8d3fb3475317aa259d7241e837ba3 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Sun, 28 Dec 2025 15:35:48 -0500 Subject: [PATCH] fix: Register keypressScene after setScene (closes #143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keypressScene() sets the handler for the CURRENT scene, so we must call setScene() first to make focus_demo the active scene before registering the key handler. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/demo/screens/focus_system_demo.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/demo/screens/focus_system_demo.py b/tests/demo/screens/focus_system_demo.py index 30884e6..fc3ba88 100644 --- a/tests/demo/screens/focus_system_demo.py +++ b/tests/demo/screens/focus_system_demo.py @@ -751,17 +751,15 @@ def create_demo_scene(): else: status_text.text = "No widget focused" - # Register key handler using Scene API - scene = mcrfpy.sceneUI("focus_demo") - # Note: We use keypressScene for function-based handler since we're not subclassing Scene + # Activate scene first (keypressScene sets handler for CURRENT scene) + mcrfpy.setScene("focus_demo") + + # Register key handler for the now-current scene mcrfpy.keypressScene(on_key) # Set initial focus focus_mgr.focus(0) - # Activate scene - mcrfpy.setScene("focus_demo") - return demo_state