Re: Event coordinates in Cytoscape.js

1,161 views
Skip to first unread message

Yue Dong

unread,
Nov 1, 2012, 6:24:48 PM11/1/12
to cytoscap...@googlegroups.com
(Here is my response, re-posted here in the mailing list)

Hi Aleksi,

cy.nodes().bind("mouseover", function(e){console.log(e)})

showed the event fields are not completely implemented.

Is there a timeframe you would like this implemented by? I can  
probably complete this in 1-2 days, depending on need.

It looks like things would be easy if we gave you access the  
w3c-standard MouseEvent object that caused the event. Would you prefer  
this? What works best for you?

Thanks,
Yue

On Tuesday, October 30, 2012 4:02:41 AM UTC-4, Aleksi Kallio wrote:
Hi all,

I'm trying to add custom tooltips to Cytoscape.js with qTip2. I found an example in http://stackoverflow.com/questions/11307914/fetching-svg-element-from-node-object-in-cytoscape-js but in there mouse coordinates are fetched with  oEvent.clientX and oEvent.clientY. I tried this but the coordinates are undefined.

Is there a way in cytoscape.js to get event coordinates?

Thanks,
Aleksi

Max Franz

unread,
Nov 2, 2012, 11:48:50 AM11/2/12
to cytoscap...@googlegroups.com
Cytoscape.js uses the jQuery event model: It creates an event object, referencing the original event.  If an event is triggered -- say in the renderer -- without passing the original event, then there isn't much information in the event you get in your callback.

You don't really need event information for what you're doing anyway.  Inside the handler callback, the reference to `this` is the element that triggered the event.  You can do `this.renderedPosition()`, `this.width()`, and so on.  This will give you enough information to position the qtip.

I will be creating a Cytoscape.js extension that let's you use qtips directly.  So if you can wait a couple of weeks, that may be the better option for you.

On Tuesday, 30 October 2012 at 04:02, Aleksi Kallio wrote:

Hi all,

I'm trying to add custom tooltips to Cytoscape.js with qTip2. I found an example in http://stackoverflow.com/questions/11307914/fetching-svg-element-from-node-object-in-cytoscape-js but in there mouse coordinates are fetched with  oEvent.clientX and oEvent.clientY. I tried this but the coordinates are undefined.

Is there a way in cytoscape.js to get event coordinates?

Thanks,
Aleksi

--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cytoscape-discuss/-/DSBS3ynUYuoJ.
To post to this group, send email to cytoscap...@googlegroups.com.
To unsubscribe from this group, send email to cytoscape-disc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cytoscape-discuss?hl=en.

Aleksi Kallio

unread,
Nov 5, 2012, 1:30:10 AM11/5/12
to cytoscap...@googlegroups.com
Thanks Max,

this.renderedPosition() worked.

Yue Dong

unread,
Nov 28, 2012, 2:10:54 PM11/28/12
to cytoscap...@googlegroups.com
Hi,

I'm not sure if you still need it, but it has been fixed. I've commited some changes, and a recent bugfix should also appear on the public docu/demo page http://cytoscape.github.com/cytoscape.js/.

You can verify by opening the console (such as on the docu page) and typing:

cy.nodes().bind("mousemove", function(e){console.log(e)})

The event object now has the originalEvent field, which contains the MouseEvent object (or TouchEvent for touch).
Reply all
Reply to author
Forward
0 new messages