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

Incorrect pointer areas for horizontal AquaRadioButtonGroup #825

Closed
pixelzoom opened this issue Jan 31, 2023 · 1 comment
Closed

Incorrect pointer areas for horizontal AquaRadioButtonGroup #825

pixelzoom opened this issue Jan 31, 2023 · 1 comment
Assignees
Labels

Comments

@pixelzoom
Copy link
Contributor

As reported in phetsims/beers-law-lab#317, the pointer areas for a horizontal AquaRadioButtonGroup are currently incorrect. For example, we have this group with spacing: 60 (see SoluteFormRadioButtonGroup.ts):

screenshot_2222

The relevant code in AquaRadioButtonGroup.ts is:

      // set pointer areas - update them when the localBounds change
      radioButton.localBoundsProperty.link( localBounds => {
        if ( options.orientation === 'vertical' ) {
          radioButton.mouseArea = localBounds.dilatedXY( options.mouseAreaXDilation, options.spacing / 2 );
          radioButton.touchArea = localBounds.dilatedXY( options.touchAreaXDilation, options.spacing / 2 );
        }
        else {
          radioButton.mouseArea = localBounds.dilatedXY( options.spacing / 2, options.mouseAreaYDilation );
          radioButton.touchArea = localBounds.dilatedXY( options.spacing / 2, options.touchAreaYDilation );
        }
      } );

For vertial orientation, it's OK to fill the vertical space between buttons with pointer area by including options.spacing in the computation. But for horizontal orientation, that's not OK, and results in exactly this kind of problem.

The solution is to rewrite the else block above like this:

        else {
          radioButton.mouseArea = localBounds.dilatedXY( options.mouseAreaXDilation, options.mouseAreaYDilation );
          radioButton.touchArea = localBounds.dilatedXY( options.touchAreaXDilation, options.touchAreaYDilation );
        }

... which in our example will result in:

screenshot_2221

@pixelzoom
Copy link
Contributor Author

Looks like I was the original author of the code in questions. So I'm going to approve and close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant