-
Notifications
You must be signed in to change notification settings - Fork 12
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
add ability to shift pointer areas for buttons #500
Comments
Summary of @zepumph suggestion on Slack:
The current API uses |
Since I can easily imagine a designer asking to "expand the touch area a bit below and more above" (which is what we'd probably want to do in phetsims/unit-rates#212), I think that the new ExpandCollapseButton( ..., {
touchAreaXDilation: 10,
touchAreaYDilation: 9,
touchAreaYShift: -3 // to have 6 below and 12 above
} ); |
A generalization (that wouldn't include as many options) would presumably be a function that returns the mouse/touch area. It could take in the as-of-yet-constructed node, e.g.: new ExpandCollapseButton( ..., {
touchAreaGenerator( node ) {
return node.localBounds.dilatedXY( 10, 9 ).shifted( -3, -3 );
}
} ); |
@jonathanolson's suggestion above is indeed very general. But...
new RectangularPushButton( ..., {
touchAreaXDilation: 10,
touchAreaYDilation: 5
}
} ); ... would become: new RectangularPushButton( ..., {
touchAreaGenerator( node ) {
return node.localBounds.dilatedXY( 10, 5 );
}
} ); |
Would it read any clearer with arrows? |
Do you mean arrow functions? Still seems heavy for the typical case: new RectangularPushButton( ..., {
touchAreaGenerator: node => node.localBounds.dilatedXY( 10, 5 )
} ); |
Occurrences of the RectangularButtonView options that would be obsoleted by @jonathanolson's proposal. Unlikely that all of these are for RectangularButtonView, but all of them would need to be examined. touchAreaXDilation 161 And since we'd presumably want to do something similar for RoundButtonView: touchAreaDilation 37 |
I'm not sure how to balance the flexibility of 1 function vs the ease of 4 variables which are often all we need. I'd like to discuss further in the dev meeting. |
4/25/19 dev meeting: I'll proceed with new options for RectangularButtonView and RoundButtonView. We can change in the future if needed. The options are: touchAreaXShift: 0,
touchAreaYShift: 0,
mouseAreaXShift: 0,
mouseAreaYShift: 0, |
This is blocked until we resolve #502. |
Done for round and rectangular push buttons. Demonstrated in sun demo application, see annotated screenshot below. @ariel-phet please assign someone to review. |
@chrisklus can you review? |
@pixelzoom looks good. The code changes make sense and I tested the shifted pointer areas with a mouse and simulated touch device. Back to you. |
In phetsims/unit-rates#212, we identified a need to shift the pointer area for a
RectangularButtonView
. In that case, it's the ExpandCollapseButton for AccordionBox.If we need arbitrary shifting, we could add this to
RectangularButtonView
:and the code that sets the pointer areas becomes:
If we don't need arbitrary shifting and want to keep the pointer areas aligned with the button, then the API might be:
and the code to set the pointer areas would be significantly more complicated.
And depending on what API we choose, we should probably add something similar to
RoundButtonView
.The text was updated successfully, but these errors were encountered: