PDA

View Full Version : Drag and drop Panels


Eugene
09-15-2016, 01:27 PM
Hi Jeff,

I've created a few panels and would like to allow the user to relocate the panel using the mouse. Similar to moving a window. May I know how can I do that in vizard?

Thanks.

Eugene

Jeff
09-16-2016, 04:41 AM
Are you referring to a vizinfo panel? There is no built-in way to do this. I'm not sure if the viz.pick command will work with objects added to viz.ORTHO, like the panel. I'll check and update here if there is a way. It maybe necessary to calculate if a mouse click is within a panel's bounds. You could try the following:

1) Calculate the panel bounds using the node.getBoundingBox (http://docs.worldviz.com/vizard/#commands/node3d/getBoundingBox.htm) method.
2) Handle the mouse down event and determine if the mouse position (http://docs.worldviz.com/vizard/#commands/viz/mouse/getPosition.htm) is inside the panel bounds.
3) Enable an update function that sets the panel position every frame based on the mouse position. The panel position takes screen coordinates and you can get the mouse position in screen coordinates.
4) Disable the update function when the mouse up event occurs.

Eugene
09-16-2016, 07:58 AM
Hi Jeff,

I'm using the vizdlg.panel() and vizdlg.TabPanel(). Would it be different?

Eugene

Jeff
09-20-2016, 06:45 AM
No, you would have to follow the same steps.