-
-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lost click event when opening popup #5788
base: master
Are you sure you want to change the base?
Fix lost click event when opening popup #5788
Conversation
The lead programmer for Thrive is currently on vacation until 2025-01-07. Until then other programmers will try to make pull request reviews, but please be patient if your PR is not getting reviewed. PRs may be merged after multiple programmers have approved the changes (especially making sure to ensure style guide conformance and gameplay testing are good). If there are no active experienced programmers who can perform merges, PRs may need to wait until the lead programmer is back to be merged. |
1977bc3
to
9e70e8a
Compare
var before = HeldDown; | ||
if (base.OnInput(@event) && !before && HeldDown) | ||
// Only trigger if the input was pressed this frame. It isn't possible to use !HeldDown since its value is | ||
// incorrect if a mouse release event is marked as handled e.g. when opening a popup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the actual fix be to make sure that up events are always handled? Because that's how I tried to design the input system in the first place. I'm sure I put in at least some code that should feed handled inputs that are release type events into the system so that the held down statuses wouldn't get stuck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, HeldDown
is only set to false in the OnInput
and FocusLost
methods. OnInput
is only called if the input is unhandled (or the attribute has OnlyUnhandled
). 'FocusLost' is only called when the window has focus lost.
Could you please point me towards the existing code? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably exactly the bug, OnInput
only passes events it sees but it has code that further key handlers are given all events if they are up events. So this situation likely needs a bit of refactoring so that handled up events would still be fed as up events into all the listeners (so I'd split OnInput into two parts, one that does the normal stuff and one that has just the event forwarding, and then I'd pass handled events that are key up events to the second part of the method).
Brief Description of What This PR Does
When opening a popup such as the organelle context menu, the mouse release event will be marked as handled by the popup. This means that the input manager won't call the OnInput function:
Thrive/src/engine/input/InputManager.cs
Lines 573 to 575 in dce65af
This caused the HeldDown field of RunOnKeyAttribute to get stuck in the true state.
I changed the RunOnKeyDownAttribute to rely on
Input.IsActionJustPressed
rather than theHeldDown
state to avoid this issue.Related Issues
I think this closes #5217?
Progress Checklist
Note: before starting this checklist the PR should be marked as non-draft.
break existing features:
https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
(this is important as to not waste the time of Thrive team
members reviewing this PR)
styleguide.
Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.