Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0HyperCube
Copy link
Contributor

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:

if (unhandledInput || !attribute.OnlyUnhandled)
{
if (attribute.OnInput(@event))

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 the HeldDown 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.

  • PR author has checked that this PR works as intended and doesn't
    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)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    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.

@revolutionary-bot
Copy link

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.

@0HyperCube 0HyperCube force-pushed the fix-lost-click-event branch from 1977bc3 to 9e70e8a Compare January 7, 2025 17:21
@hhyyrylainen hhyyrylainen added this to the Release 0.8.1 milestone Jan 8, 2025
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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
3 participants