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.

Multiple Objects post and replies

Return to the Multiple Objects thread
Login to post to this thread

Multiple Objects onclick
Apostolos Michaloudis
28 Posts


I create a list of texts in drawing panel, each of them has defferent position in y axis,
by using a matrix var y[i].

Is it possible, when I click on a text to return the i number of this particular text,
without a for loop?

Best regards!

Replies to Multiple Objects onclick

Re: Multiple Objects onclick -
Francisco Esquembre
232 Posts


As with any set of drawables, the ElementInteracted gives you the integer index of the element you interacted with.

See example attached. (Notice that texts' hot point is on top its first character...)


Attached File: ejss_src_SetInteractionTest.zip

OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book