APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

How do I get the x and y coordinate in javascript in PlotPanel on mousedown

Return to the EJS Modeling forum
Login to post to this thread

How do I get the x and y coordinate in javascript in PlotPanel
John Val
13 Posts

Dear all,

I would like to start a simulation from a point under a mouseclick in the plotpanel in the javascript version.
In the plotting panel of the FunctionPlotter example I enabled interaction and put
%mouseClick% at the Onpress event.

In this functioen I would like to read the x and y postion under the cursor.
I know I must be able to get them somewhere since in the lower left corner a box with these values appears.

function mouseClick() {
    var x= _view.plottingPanel.pointer.x; //  this does not work. But what does?
    alert(x);
}


Current Replies - View all
Re: How do I get the x an...   (Wolfgang - )
Re: Re: How do I get the ...   (John Val - )
Re: How do I get the x an...   (Francisco Esquembre - )
Re: How do I get the x an...   (John Val - )
OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book