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

event.currentTarget is null in SimpleDragHandler 'drag' #66

Closed
pixelzoom opened this issue Jun 5, 2013 · 7 comments
Closed

event.currentTarget is null in SimpleDragHandler 'drag' #66

pixelzoom opened this issue Jun 5, 2013 · 7 comments
Assignees

Comments

@pixelzoom
Copy link
Contributor

This prints 'null':

node.addInputListener( new SimpleDragHandler() {
  drag: function( event ) {
      console.log( event.currentTarget );
  }
} ); 

Event.js says:

// {Node} whatever node you attached the listener to, or null when firing events on a Pointer
    this.currentTarget = args.currentTarget;

Perhaps in the implementation of SimpleDragHandler, 'drag' is firing on a pointer. If that's the case, it's not at all obvious to the client. If dealing with event.currentTarget in the 'start' and 'end', I would hope to be able to do the same in 'drag'. If I have to use event.currentTarget in one place and event.trail another, that's unfortunate.

@pixelzoom
Copy link
Contributor Author

I'm experiencing the same problem with ButtonListener 'over'. It occurs when I release the mouse with the cursor over the node. event.currentTarget is null, oldState is down'. I realize that this is probably because something is being handled via a pointer listener, but I think that needs to be transparent to the client.

@jonathanolson
Copy link
Contributor

SimpleDragHandler (and other drag listeners) could overwrite currentTarget with the node the listener is applied to, if that would make things easier.

@pixelzoom
Copy link
Contributor Author

Yes, please overwrite (fill in?) currentTarget in SimpleDragHandler. Ditto for ButtonListener and UpDownListener. From the client's perspective, these listeners are added to a node (not a pointer) so event.currentTarget should be valid.

@pixelzoom
Copy link
Contributor Author

Discussed at 6/6/13 developer meeting, assigning this to me.

@ghost ghost assigned pixelzoom Jun 6, 2013
@pixelzoom
Copy link
Contributor Author

I filled in currentTarget in DownUpListener, and ButtonListener requires no changes because it's a subtype of DownUpListener. JO reviewed it, and it's working in molarity and beers-law-lab.

SimpleDragHandler is next, unless JO delivers better drag handler before I get to it. I'm planning to reorganize SimpleDragHandler a bit, move some of the code that's currently in the pointer listener into the SimpleDragHandler.prototype functions, so that all assignment to event.currentTarget are done in the prototype functions. With the current structure, assignments would be spread across pointer listener and prototype functions.

@jonathanolson
Copy link
Contributor

Is this waiting on anything for me to do before the deadline, or should it be removed from the milestone? I can work on creating DragListener, but I don't see it as the highest priority right now.

@pixelzoom
Copy link
Contributor Author

Since it's been another month and we haven't replaced SimpleDragHandler, I decided to fix this. @jonathanolson, could you please review the fix?

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

No branches or pull requests

2 participants