-
Notifications
You must be signed in to change notification settings - Fork 8
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
Make it possible to disable dragging the laser, while still being able to turn the button on and off #397
Comments
At today's design meeting, @arouinfar and @kathy-phet also commented that we should be able to disable drag/rotate independently. |
Ideally any solution in phetsims/scenery#1041 wouldn't involve working on deprecated listeners. Is part of the Bendling Light work to upgrade LaserNode's SimpleDragHandlers to |
We discussed that maybe removing the knob is how you make it non-rotateable. |
I added |
Yep, this is what I had in mind (in bending-light, and more generally for phetsims/scenery#1041). I played with bending-light in Studio, and (to me) this method of enabling/disabling interaction feels superior to setting pickable, or (worse) having to find and disable listeners that are relevant to some interaction that you want to turn off. Some recommendations:
|
On the prisms screen, disabling |
Ah, I missed that on the Prisms screen. But you get the point, right? |
Yes, I'm working on removing it from that case. |
This would address my concerns: Index: js/common/view/LaserNode.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/view/LaserNode.js b/js/common/view/LaserNode.js
--- a/js/common/view/LaserNode.js (revision a5b9562b142dddb1ba0299c3e1c8383e60b4695f)
+++ b/js/common/view/LaserNode.js (date 1612925642727)
@@ -215,19 +215,21 @@
}
} );
- const isTranslationEnabledProperty = new BooleanProperty( true, {
- tandem: options.tandem.createTandem( 'isTranslationEnabledProperty' )
- } );
- isTranslationEnabledProperty.lazyLink( isEnabled => {
- if ( isEnabled ) {
- translationTarget && translationTarget.addInputListener( translationListener );
- translationTarget && translationTarget.addInputListener( translationOverListener );
- }
- else {
- translationTarget && translationTarget.removeInputListener( translationListener );
- translationTarget && translationTarget.removeInputListener( translationOverListener );
- }
- } );
+ if ( translationTarget ) {
+ const isTranslationEnabledProperty = new BooleanProperty( true, {
+ tandem: options.tandem.createTandem( 'isTranslationEnabledProperty' )
+ } );
+ isTranslationEnabledProperty.lazyLink( isEnabled => {
+ if ( isEnabled ) {
+ translationTarget.addInputListener( translationListener );
+ translationTarget.addInputListener( translationOverListener );
+ }
+ else {
+ translationTarget.removeInputListener( translationListener );
+ translationTarget.removeInputListener( translationOverListener );
+ }
+ } );
+ }
// update the laser position
laser.emissionPointProperty.link( newEmissionPoint => { |
Side issues... These lines seem unfortunate. Why even create these listeners if there is no translatonTarget? 143 translationTarget && translationTarget.addInputListener( translationListener );
154 translationTarget && translationTarget.addInputListener( translationOverListener ); This is also mega confusing, since knobImage might actually be const translationTarget = hasKnob ? laserPointerNode : knobImage;
const rotationTarget = hasKnob ? knobImage : laserPointerNode; Somehow we're supposed to figure out what the knob is used for. The above code makes it look like the knob is sometimes used for translation, but I'm pretty sure (but not certain) that it never is, and const translationTarget = hasKnob ? laserPointerNode : null; ... and I still don't understand the semantics of |
I think I addressed all of the recommendations in the commits, can you please review at your convenience? |
Changes looks good, and address my concerns about isTranslationEnabledProperty.
If it were me, I would (1) document that LaserNode is always rotatable, (2) always show the knob, since there's no harm in doing so and imo it's confusing that it's removed, and (3) replace
... but up to you whether you want to do anything about |
FYI, amy and I identified several more applications of this issue in our projectile motion review this week, so MK you will get to try any approach there also.
…Sent from my iPhone
On Feb 9, 2021, at 8:20 PM, Chris Malley ***@***.***> wrote:
Changes looks good, and address my concerns about isTranslationEnabledProperty.
hasKnob is still way too overloaded for my taste. I've figured out that it means:
true - add a knob, make the laser rotate by dragging the knob, translate by dragging the laser body
false - don't add a knob, make the laser rotate by dragging the laser body, don't support translation
If it were me, I would (1) document that LaserNode is always rotatable, (2) always show the knob, since there's no harm in doing so and imo it's confusing that it's removed, and (3) replace hasKnob with isTranslatable:
@param {boolean} isTranslatable
true: the laser can be translated by dragging it by the laser body, rotated by dragging it by the knob
false: the laser cannot be translated, and can be rotated by dragging anywhere on the laser
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Tagging @zepumph to make sure he is aware of the progress in this issue and the preceding comment about Projectile Motion. I will move the recommendations from #397 (comment) to a separate issue, closing. |
@zepumph the cannon in Projectile Motion can be adjusted in two ways:
Clients should be able to independently disable these interactions (whether by pickableProperty or something else). I'll include this request in the issue for the Projectile Motion design review. |
In phetsims/scenery-phet#660 (comment) @arouinfar said:
Note that a solution/workaround was proposed in phetsims/scenery#1041 (comment)
The text was updated successfully, but these errors were encountered: