This is a migrated thread and some comments may be shown as answers.

PanTool and Item Selection

1 Answer 102 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
GR
Top achievements
Rank 1
GR asked on 07 May 2013, 04:41 PM
Is there a way to prevent diagram items from being selected and moved while the active tool is the pan tool?  When pan is enabled, I would like item manipulation to be disabled.  As I see it, pan only works on empty areas of the diagram.

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 10 May 2013, 10:47 AM
Hello,

I already answered to this question in your support ticket. However, I will also post the same answer in this forum thread so that others from the community will be able to find it.

This behavior is not supported out-of-the-box. However, in order to achieve your requirement, you can use the IHitTestService. This service is called on each MouseDown event. Hence, if the diagram doesn't know that there is an item under the mouse (when you want to pan) the control will start pan operation otherwise (if the control knows that there is a shape under the mouse) it will start drag operation. You can do this by subscribing to the PreviewMouseLeftButtonDown event of the RadDiagram control and setting the ItemUnderMouse property of the service to return null.

Furthermore, in order to allow the dragging of items when the CTRL key is not pressed you will have to set back the default service. This can be done in the MouseUp event handler of the RadDiagram control.

For your convenience we implemented this approach in the attached project. Please take a look at it and let us know if it works in your certain scenario.

On the other hand, the same functionality can be achieved by setting the IsEnabled property of any item to False. By doing so, you will be able to start panning on top of the that item and you will disable it (and its manipulations).

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
GR
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or