Given I have several cubes drawn on the canvas, how can they be moved independently of each other? How to define distinct onmouseup/onmousedown/onmousemove listeners to each cube?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You normally have only one pointer on the screen, except in multitouch environments, or where individual pointers can be requested for each input device.
So having only one set of mouse event handlers is kind of natual. If you want some distinction between the objects, you must get creative and come up with some way to associate event position with the to be changed object. For example clicking on it.
OpenGL is just a drawing API. It doesn’t deal with objects, it doesn’t know what a mouse is, or what input events are and it doesn’t manage a scene, which also means it won’t give you free candy in form of per-object-listeners. All of this must be implemented by you (or some 3rd party library).