Page 1 of 1

DraggingTool: Keylistener / other mouse button combination

Posted: Fri 3. Oct 2008, 15:08
by Joe
Hi,
I am using the DraggingTool class. I found out that it can also be used for dragging along the z axis by pressing <ctrl> and center mouse button while moving the mouse. But: The <ctrl> key works only if I do a left click to the canvas. Otherwise the corresponding keylistener seems not to be listening. The mouselistener is working without clicking the canvas with the left mouse button.

I tried to request the focus in the "activate" method of the DraggingTool (viewer.getViewingComponent().requestFocus()), but it didn't work.

Now two questions:
1. Is it possible to create a workaround in the DraggingTool to make the <ctrl> key working without clicking the canvas?
2. Instead of the <ctrl> key, can I modify the DraggingTool to be activate if the center and the left mouse buttons are pressed together? The RotateTool should not be activated in this case (because if only the left mouse button is pressed, a rotation is done).

Many thanks and best regards, Joe

Posted: Tue 14. Oct 2008, 10:02
by gunn
Joe,

I can't reproduce the problem. I don't need to left-click on the canvas in order for ctrl-middle to produce z-translation. What system are using to run jReality? (OS, hardware, etc)

As far as using left-middle mouse to produce z-translation: the tool as it's currently written won't allow that, since it's only activation slot is the middle mouse ("DraggingActivation"). The rotate tool gets the left mouse as its activation; it doesn't pay attention to the middle mouse press so you get a normal rotate. However, if you remove the rotate tool, then the drag tool gets the middle mouse activation, sees that the left mouse is also down, and then does the z-translation as desired. The key is that the left mouse comes first as activation element, and lands in the rotate tool. If you trying to do something similar with the rotate tool I think it would work, since the left mouse would properly activate the rotate tool.


Charles

Posted: Sun 26. Oct 2008, 20:40
by Joe
Thanks for your answer and sorry for my late replay. I found a very old version of jreality.jar in my classpath. After removing it, a left click into the canvas isn't necessary anymore.