How to limit handle dragging

I am reaching out to inquire about the best practices for limiting the maximum movement of a handle during a drag operation. Specifically, I would like to understand how to implement a restriction that prevents the handle from being dragged beyond boundingBox

Hello @wwj8867486,

Among the callbacks in Communicator is handleEvent which is triggered when the geometry of the handle operator is moved. Four parameters are returned: eventType, nodeIds, initialMatrices and newMatrices. So if the eventType is “Translate”, you will have to use the returned modelling matrices for the node to determine its position and limit the range of translation. For the type of control you want, in addition to using the callback, it may require writing your own custom handle operator. As a reference, please see HandleOperator.ts found in HOOPS_Communicator_2024.X.x\web_viewer\deprecated\typescript\operators.

Thanks,
Tino

Thank you very much for your explanation. I have one more question: How different is the code in the deprecated directory, like HandleOperator.ts, compared to the current version I’m using 7.1? Is it just one version behind, or are there other differences? I’m planning to use operatorManager.replaceOperator(Communicator.OperatorId.Handle, customHandleOperator), and I’m concerned that this might introduce unexpected bugs.

The algorithm and logic is the same so we would not expect issues in that regard.

1 Like