Skip to content

Fix #9393: Consistent _buttonDown usage in ScreenSpaceEventHandler.js #12613

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

Merged
merged 5 commits into from
Jul 29, 2025

Conversation

ayushd150
Copy link

@ayushd150 ayushd150 commented May 10, 2025

Changes made to _buttonDown in ScreenSpaceEventHandler.js

Fixes #9393

Copy link

github-actions bot commented May 10, 2025

Thank you for the pull request, @ayushd150! Welcome to the Cesium community!

In order for us to review your PR, please complete the following steps:

Review Pull Request Guidelines to make sure your PR gets accepted quickly.

@ayushd150
Copy link
Author

I have signed the CLA in Google Forms

@ayushd150
Copy link
Author

Added myself in the Contributors.md file

@ggetz
Copy link
Contributor

ggetz commented May 13, 2025

Thanks @ayushd150!

First things first, could you let us know the reason for the change? It looks like this may be a fix for #9393, is that correct?

If we do want to move forward with this PR–

  • I can confirm we now have a CLA on file for you.
  • Could you please pull your change from Update CONTRIBUTORS.md #12614 into this branch so we can review everything together?

Copy link
Contributor

@jjspace jjspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ayushd150. I had a few comments about this approach, see below.

It also seems like you have a bunch of package.json and formatting changes on this branch. I'm assuming these just got added by mistake but please resolve/remove them to focus only on the code changes made.

Also you can include the updates to CONTRIBUTORS.md in this pr instead of a separate one. @ggetz beat me to it 😆

Comment on lines 977 to 981
this._buttonDown = {
LEFT: false,
MIDDLE: false,
RIGHT: false,
0: false, // LEFT
1: false, // MIDDLE
2: false, // RIGHT
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this initialization should still rely on the values from MouseButton so they're consistent. You can set the properties dynamically using the enum constants.

this._buttonDown = {
  [MouseButton.LEFT]: false,
  [MouseButton.MIDDLE]: false,
  [MouseButton.RIGHT]: false,
}

if (screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) {
if (screenSpaceEventHandler._buttonDown[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is functionally equivalent but harder to read. If you check the initialization of MouseButton on line 45 you can see the values are already integers. We should use that enum/constants everywhere else for readability. Please undo the changes like this one.

@ggetz ggetz mentioned this pull request Jun 13, 2025
6 tasks
@jjspace
Copy link
Contributor

jjspace commented Jul 29, 2025

I went ahead and pushed the changes from my comment above so we can try and get this merged. @lukemckinstry or @mzschwartz5 would you be able to take a quick look at this and merge if happy? You can check #9393 for some context

@mzschwartz5
Copy link
Contributor

I went ahead and pushed the changes from my comment above so we can try and get this merged. @lukemckinstry or @mzschwartz5 would you be able to take a quick look at this and merge if happy? You can check #9393 for some context

I'll take a look

@mzschwartz5 mzschwartz5 self-requested a review July 29, 2025 16:33
@mzschwartz5 mzschwartz5 enabled auto-merge July 29, 2025 16:35
@mzschwartz5 mzschwartz5 added this pull request to the merge queue Jul 29, 2025
Merged via the queue into CesiumGS:main with commit f7f920a Jul 29, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent usage of _buttonDown in ScreenSpaceEventHandler
5 participants