NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
November 19, 2017, 12:01:19 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
"Vision, mission and action." ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: How do I get the cursor position in a running plotting panel?  (Read 5011 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Abyss333
Newbie
*
Offline Offline

Posts: 3

«
Embed this message
on: October 21, 2010, 01:44:59 am » posted from:Hamburg,Hamburg,Germany

Hello

I'm trying to create a "Game of Life" (John Conway) with EJS and I have the problem that I'm not able to get the cursor position in my plotting panel.
Heard something about that the position is accesable via the properties of my plotting panel but I really don't know how to put it in my algorithms because I don't know the exact methods for the positions on X-axis as well as the Y-axis.

Thanks for help.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #1 on: October 21, 2010, 12:30:46 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

see my mx , my
mx =mouse coordinate in x
my =mouse coordinate in y

u can download it http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1027.0

how mx, and my is used to detect the mouse position.

there are also many other applets from Professor Fu Kwun Hwang that has mx and my Smiley
it is one which i adapted from him.


* mousemxmy.PNG (30.61 KB, 483x612 - viewed 644 times.)
« Last Edit: October 21, 2010, 12:33:27 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #2 on: October 21, 2010, 12:50:40 pm » posted from:Taipei,T'ai-pei,Taiwan

As lookang suggested:

 Define mx,my as variables to store value for cursor position, and assigned them to "Pos x" and "Pos y"

And EJS will find cursor position and translated to current plottingPanel coordinates , and assigned value to mx,my

Normally, I  will access mx,my values from action code in "OnPress, OnDrag,OnRelease, OnEnter,OnExit"

e.g. at r=Math.sqrt(mx*mx+my*my) in OnDrag
will find distance between origin and cursor position in plottingPanel
when you click and drag mouse inside plottingPanel
 
Logged
Abyss333
Newbie
*
Offline Offline

Posts: 3

«
Embed this message
Reply #3 on: October 21, 2010, 09:40:06 pm » posted from:Hamburg,Hamburg,Germany

Wow, thank you  Grin

That will help me alot in my EJS programming.  Cheesy
Logged
Pages: [1]   Go Up
  Print  
"Vision, mission and action." ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
General purpose Curve plotting applets
Kinematics
Fu-Kwun Hwang 3 18566 Last post April 15, 2016, 11:37:02 pm
by lookang
how to draw a fraction of a circle for angle showing in plotting panel
Questions related to EJS
lookang 7 16388 Last post August 15, 2007, 08:55:15 am
by Fu-Kwun Hwang
Plotting signals to a time-base.
Request for physics Simulations
bobminor 2 8759 Last post January 02, 2008, 04:16:34 am
by bobminor
Position vs. Time
Request for physics Simulations
lookang 11 14868 Last post March 11, 2009, 07:47:34 pm
by lookang
Ejs Open Source Position, velocity, and acceleration graphs
Collaborative Community of EJS
lookang 1 9412 Last post March 12, 2009, 01:22:58 pm
by lookang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.3 seconds with 22 queries.since 2011/06/15