You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nsgotest: BlurWindow leaves keys held with KeyCodeDown in KeyCodesDown #2248
nsgotest.App.BlurWindow is documented to release "every held key and held mouse button just as desktop and web platforms do on focus loss". For a key held with KeyCodeDown, the key-up it sends is wrong, so the key stays in core.KeyCodesDown and a view's OnKeyUp never hears its position come up.
a.held is keyed by identity, which press in nsgotest/steps.go sets to the physical code when the key was pressed with KeyCodeDown (identity := code). So the event carries Text: "KeyW" and no KeyCode. The normal path, release in nsgotest/steps.go, sends Text: h.name, KeyCode: h.code, which is what BlurWindow should send too.
Why it matters
A game that binds actions by physical position (WASD on any layout) reads core.KeyCodesDown and needs the focus-loss release to work, or the character keeps walking after the window loses focus. In nsgo-dev/game the input package's WatchKeys test has to hold keys by name instead of by code for the blur case, because the code-held variant cannot pass against BlurWindow today.
In BlurWindow, dispatch driver.Event{Kind: driver.EventKeyUp, ID: h.id, Text: h.name, KeyCode: h.code}, matching release, and add a test next to the existing BlurWindow tests that holds a key with KeyCodeDown and checks KeyCodesDown, KeysDown and OnKeyUp after the blur.
Acceptance
After KeyCodeDown("KeyW") and BlurWindow(), core.KeyCodesDown is empty and OnKeyUp hears KeyEvent{Key: "w", Code: "KeyW"}.
A key held by name with KeyDown still comes up with its name, as today.
Activity
fix(nsgotest): release physical keys on window blur