-
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
Should nodes have pickable:false by default? #105
Comments
Sound like a nice convenience, but... I frequently have a scenery.Node that is used as the parent for building a more complicated interactive object. I want the entire object to be interactive, so I add my InputListener to the parent Node. So which node(s) are then automatically switched to pickable:true? If it's just the parent Node, then the children are still pickable:false and I have nothing to interact with. If all children also automatically get pickable:true, then there will be an ordering dependency; I'll have to add children before adding the InputListener. Or something an additional check will need to be introduced in addChild to see if any ancestor has an InputListener. Something similarly messy for removeChild. |
@pixelzoom makes a good point. I'm happy to close this ticket, but perhaps I'll assign it to @jonathanolson to have him veriew and verify first. |
When this issue was created, I would imagine that adding in an event listener on a node would make that node and all descendants implicitly pickable, but a node that doesn't have an input event listener in its trail (to the scene root) would be by default unpickable. |
Well, that's going to introduce an order dependency then. If you have any descendants that shouldn't be pickable, you'll need to set their pickable:false after calling addInputListener. And what happens on removeInputListener? Does the node and all of its descendents revert to pickable:false? Smells like trouble. |
It would just mean we would need to introduce a default of something like pickable: undefined (meaning it is pickable if there is a node in its trail with an input listener), pickable: false and pickable: true would still behave as expected. Note that undefined/false/true may not be the best choice, we could go with an enumeration pattern, etc. |
Pickable: undefined sounds like it might work well (though it would probably need a better name). I'd be interested to hear @pixelzoom thoughts about that, or if there are any anticipated problems with that. But I should say, having to manually specify 'pickable:false' in my non-pickable nodes doesn't really slow me down too much. |
I think we should leave things as is (default to pickable:false). We have bigger fish to fry, and I don't see this as significant overhead. |
An alternate proposal:
This means the default is "pass-through" for all nodes without listeners attached. If you want a node to "block" events, you need to explicitly set pickable: true. The hit testing performance would be optimized with this, and would reduce sim 'picakble' flags. It would come at the cost of slightly increased Scenery complexity, but I believe the performance benefits would be overall a net plus. |
pickable: null (instead of undefined) |
10/3/13 dev meeting consensus: @jonathanolson proposal sounds good, use null instead of undefined. |
From the documentation (for precision):
|
To optimize the performance of a sim, one of the steps is to visit all of the non-interactive nodes and set pickable:false. Would it be better for pickable:false to be the default, and when an input listener is added pickable can automatically switch to true?
The text was updated successfully, but these errors were encountered: