1

using http://www.flotcharts.org/ to realize a complex scatterplot graphic with zoom/pan functionalities, i would like to set mouse position at specific coordinates (by example: when doing a zoom in, I would like that cursor would positioned at the center of canvass).

It ssem this function doesn't work:

  function setMousePosition(pos) {

  var x = pos.x;
  var y = pos.y;

  var pointX = ( Math.floor(plot.offset().left + plot.p2c(pos).left) );
  var pointY = ( Math.floor(plot.offset().top + plot.p2c(pos).top) );

 $("#placeholder").mouseXPos( pointX ).`mouseYPos`( pointY );

About mouseXPos and mouseYPos, firebug say: TypeError: placeholder.mouseXPos is not a function

So my question is: there is a way in javascript or jquery to set mouse coordinates inside a graphic area ?

Giorgio Robino
  • 2,148
  • 6
  • 38
  • 59
  • I dont think this is possible at all. – techfoobar Nov 10 '12 at 09:14
  • It is not possible through jquery. Check this SO post for all details [jQuery Set Mouse Position (not cursor position)](http://stackoverflow.com/questions/1208729/jquery-set-mouse-position-not-cursor-position) – Ravi Y Nov 10 '12 at 09:17

2 Answers2

4

The mouse position cannot be set/changed via JavaScript.

techfoobar
  • 65,616
  • 14
  • 114
  • 135
2

There is no any mechanism to place a cusror to specific position programmatically in Javascript

sohel khalifa
  • 5,602
  • 3
  • 34
  • 46
  • I find a workoround... instead of move mouse (I understandis impossible), I visualize dynamically (creating on-the fly a
    ) a sort of mouse pointer marker (a simple CSS flashing rectangle)
    – Giorgio Robino Nov 10 '12 at 13:10
  • I can't agree that this is a missing feature, I don't want to be in a position where I might be forced to click a particular button to regain control of my mouse. I hadn't considered it before, but I think that the lack of programmatic control of a user's mouse is a feature, *not* a bug. – David Thomas Nov 10 '12 at 13:11