Skip to content

fix(nsgotest): release a key held by code on blur - #2360

Merged
houko merged 1 commit into
nsgo-dev:mainfrom
Laotree:fix/blur-key-codes
Nov 25, 2026
Merged

houko merged 1 commit into
nsgo-dev:mainfrom
Laotree:fix/blur-key-codes

Conversation

@Laotree

@Laotree Laotree commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

nsgotest's BlurWindow releases every held key, as the desktops and the web do on focus loss, but it sent the key up with the held key's map identity in Text and no KeyCode. The identity is the physical code for a key pressed with KeyCodeDown, so the release carried Text: "KeyW" instead of the key name, and a game binding actions to physical positions kept them held: core.KeyCodesDown never emptied and OnKeyUp never heard its position come up.

Dispatch the name and code the normal release path uses.

Fixes #2248.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None; nothing visible changes.

Verification

  • New test TestBlurWindowReleasesKeysHeldByCode holds KeyW with KeyCodeDown, blurs the window and checks that core.KeyCodesDown and core.KeysDown are empty and that OnKeyUp heard KeyEvent{Key: "w", Code: "KeyW"}. On main it fails with after BlurWindow: "[KeyW] [w]"; with the change it passes.

  • A key held by name still comes up by name, which the existing TestMouseDownUpHeldButtonsAndBlurWindow covers together with the buttons.

  • go tool nsgo test ./nsgotest -count=1: 242 passed, 0 failed, 1 skipped.

  • go run ./tools/changelog check passes with the new fragment.

  • go tool nsgo check

  • go tool nsgo test

  • go tool nsgo test -target <target> on the targets above

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md. The documented behaviour was already right; the fragment is changelog.d/blur-window-releases-coded-keys.md.
  • New third-party code, assets and dependencies name their source and license. None are added.

🤖 Generated with Claude Code

BlurWindow sent a held key up with the map's identity in Text and no
KeyCode, so a key pressed with KeyCodeDown stayed down: KeyCodesDown
never emptied and OnKeyUp heard the code where the name belongs.
Dispatch the name and code the normal release uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation size/S labels Nov 25, 2026
@houko houko self-assigned this Nov 25, 2026

@houko houko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed against origin/main and issue #2248. BlurWindow now dispatches the held key's logical name and physical code, and the regression test verifies both key sets and OnKeyUp. Targeted go tool nsgo test ./nsgotest -run 'TestBlurWindowReleasesKeysHeldByCode$' -count=1 passed. All GitHub checks are green. Approving.

@houko
houko merged commit 9338d37 into nsgo-dev:main Nov 25, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nsgotest: BlurWindow leaves keys held with KeyCodeDown in KeyCodesDown

2 participants