Hello, the question might sound weird but this is something that really confuse and annoy me.
I want to be able to make some drag and drop, but in a way that when i drag something on something else, the left mouse release detect where my mouse is at that moment and change one variable in the button am over with the dragged object. This would be really easy, if i actually could detect what button am over with my mouse, but it won’t work and i can’t find a way to do it, cause when i keep the left button clicked, nothing seem to be responding.
I want to drag those things over button cause i then need those button to work after, but really i can’t find a way around… any suggestion?
See the source code of FlyCam.
It’s possible to detect mouse click/unclick in the function OnAction .
You must add a mapping in registerWithInput.
To get the mouse position:
Vector2f click2d = inputManager.getCursorPosition();
Not realy sure what you mean by all of this… i don’t use the flycam, and i must admit i don’t know much about the mapping… what i do know is that the boolean in the screen class of tonegod that decide if it will or not try to detect the mouse movement is set as private, meaning i can’t do much on that side. BUT after some reading (like 2-3 hours) on the Screen class source code i did find my anwser. Turn out a simple ray could do the job and something like this
Vector3f guiRayOrigin = new Vector3f() ;
CollisionResult lastCollision ;
CollisionResults results = new CollisionResults() ;
Ray elementZOrderRay = new Ray();
public Element getElementAtMouse()
guiRayOrigin.set(Mouse.getX(), Mouse.getY(), 0f);
Element testEl = null, el = null;
for (CollisionResult result : results)
if (result.getGeometry().getParent().getUserData("boutton") != null)
testEl = ((Element)(result.getGeometry().getParent()));
return testEl ;
get the job done pretty well. Now, am still kinda confuse about why i could not found a method that could have done that for me, but i might have miss it i guess. Anyway, thanks you for the help.