Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
I found out issue #578 while writing a test. Then found out there was a PR for it #587 that's been on hold for +2 months. I hope it's alright taking the liberty to finish this. Credit for the fix still goes to @lxkarp, since I just added a couple test on top of their branch and code.
The previous PR asked for more tests to check the
is_action_just_pressed
andis_action_just_released
methods worked ok.Goal
Close #578
Add the requested
just_pressed
andjust_released
tests.Note on potential issue
I'm not sure if this is expected behavior, but I think some resources are being leaked from one test to the next. I was getting weird results like 1 key pressed and 2 keys released. I think the
InputSender.release_all()
andInputSender.clear()
weren't being processed before the next test started. So when the second test started, theInputSender.release_all()
was processed and it detected the key release from the previous test.I fixed this by waiting for 1 frame after the
InputSender.release_all()
method is called, in theafter_each()
method. If this is expected, maybe it should be documented and added to examples. If it isn't, I can write an issue for it. I'll wait for your feedback before doing anything 🙂