In-game, clicking the mouse sometimes causes all pressed buttons to be cleared after using EditText.IsSelectionActive
Release Type: Github
Version: Main branch from yesterday, but it has been happening for months. Since I first started using the engine in 4.1.
Platform(s): Windows
Describe the bug Sometimes, when clicking, all the currently down keys are cleared (I'm still holding the key down physically on my keyboard)
To Reproduce The InputSourceBase for my keyboard is InputSourceWinforms.
For a UI page, I am forcing selection of an EditText with myEditTextElement.IsSelectionActive = true; in the update function for a period, then collapsing the page. After collapsing the page, the bug occurs.
Once it starts happening, it will occur repeatedly. Adding myEditTextElement.IsSelectionActive = false; when it is hidden, makes it occur only once. That behavior seems fine.
Expected behavior The pressed keys remain pressed.
Additional context I have a fix for this that seems to work: deleting InputSourceWinforms.UIControlOnLostFocus. I'm not sure what that's even supposed to do in the first place! So I have low confidence for just submitting a PR with that... may break something I don't know about.
That function has a comment on it:
// Release keys/buttons when control focus is lost (this prevents some keys getting stuck when a focus loss happens when moving the camera)
But I haven't seen this occur ingame since I removed the code earlier today, although I'm not sure what its referring to specifically.
@Eideren is this at all related to https://github.com/stride3d/stride/pull/1897 or https://github.com/stride3d/stride/issues/94?
UIControlOnLostFocus is for when you tab out of the application, or when another application takes the focus away by itself, we don't want to have the game thinking that keys are still held down when they aren't, it may already be taken care of though.
From what I understand, this issue occurs in game, and the lines I added only affects the editor, while those I removed were never activated as the preprocessor is never defined. Though you could validate this just to be sure.
Okay, I was wondering if that was for the application as a whole or something like input fields. Testing out a few code changes for fullscreen, mouse locking, and the way I get input in my console UI page (since using it seems to make the bug occur)
I do vaguely remember pulling that fix for the editor camera stuttering! The bug felt very similar, I thought it was the same thing until that got fixed and my ingame problem still occurred. But it's been so long all that was left was a vague memory of something happened in editor, too. I will edit my first post to make it more clear it is exclusively ingame.
I figured out what causes it to occur! In a UI component, I am forcing selection with myEditTextElement.IsSelectionActive = true; in the update function for a period, then collapsing the page. After collapsing the page, the bug occurs.
Adding myEditTextElement.IsSelectionActive = false; when it is hidden, makes the problem occur only once, instead of repeatedly. That behavior seems fine.