Jump to content
Developer Wiki and Function Reference Links ×

Cursor location after object drag


JBenghiat

Recommended Posts

Is there a way to figure out when dragging an object is complete, and get the location of where the user released the mouse?

 

On first review, the only way I can see to do this is store the cursor location during OnDrag() to a static variable, and then on object move check if that variable has data -- but that seems a little tedious.

Link to comment

I think that is exactly what you should do. I'm using this in one of my tools in "OnDrag()" and it does the job.

 

Quote

    WorldPt3 CurrentPoint;
    gSDK->GetToolPtCurrent3D(CurrentPoint);
    
    WorldPt3 DragOrigin;
    gSDK->GetToolPt3D(0, DragOrigin);   

    WorldPt3 DraggingOffset = CurrentPoint - DragOrigin;
    WorldPt3 DraggingDirection = DraggingOffset; DraggingDirection.Normalize();
    DraggingOffset.z += (WorldCoord) Utility::GetLayerElevation();

 

Edited by Hippocode
Link to comment
2 hours ago, JBenghiat said:

@Hippocode I’m just curious where you’re storing the cursor values so you can retrieve it after the event, especially when multiple objects are selected. A custom parameter seems like the easiest option, but that seems like a lot of overhead. 

 

In my case it was stored within the drag event sink itself, I believe you are trying something different. I would guess these two options could be useful?

- Using "VWDataSerializerSimple" class to store the data directly into the object. I'm using this more and more because it's less work to maintain compared to records and fields.

- In case the value is unique you could also store in permanent memory by using a VCOMImmediateImpl<IVWSingletonUnknown> interface. You could import/export into a custom interface which is accessible during the full execution of Vectorworks. Remember to handle document changes etc if you go this route.


 

Link to comment
15 minutes ago, Hippocode said:

Using "VWDataSerializerSimple" class to store the data directly into the object. I'm using this more and more because it's less work to maintain compared to records and fields.

Where is this class?  How do I access this class? How do I store data in a (this) class?

 

TIA!

Link to comment

I think I might have a different solution.

 

In the move state event, if the object has been dragged, gSDK->ClickDragToolStatus() returns kToolCompleted, otherwise, it returns kToolWaitingForFirstPoint.

 

ISDK::GetToolPtCurrent3D() seems to be correctly returning the coordinates of the mouse-up, which then lets you calculate the transformation offset and ignore ObjectStateData_Position::fTransformOffset.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...