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

Pan without Ctrl being pressed and deselect all items on mouse click

3 Answers 132 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Ciro
Top achievements
Rank 1
Ciro asked on 29 Apr 2015, 06:25 PM

Hi,

 

I want to use Pan without press Ctrl. I have reach this result using the advice from the following thread

 http://www.telerik.com/forums/pan-without-ctrl-being-pressed

Now, I want to improve this functionality and when I select one or more shapes and/or connections I want  to deselect them when I click out of the select area. Is there a way to reach this result?

Thanks 

 Ciro

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 30 Apr 2015, 01:13 PM
Hi Ciro,

When the default tool (PointerTool) is set as ActiveTool the desired functionality is provided out of the box. However, when the ActiveTool is the PanTool this behavior is not presented and you will need to implement it with custom code. Basically, you can subscribe for the MouseLeftButtonDown event of RadDiagram and inside its handler, if there is not item under the mouse, clear the selection. Here is an example in code:
this.diagram.ActiveTool = Telerik.Windows.Diagrams.Core.MouseTool.PanTool;
this.diagram.AddHandler(RadDiagram.MouseLeftButtonDownEvent, new MouseButtonEventHandler(diagram_MouseLeftButtonDown), true);
 
.....
 
private void diagram_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var hitTestService = this.diagram.ServiceLocator.GetService<IHitTestService>() as HitTestService;
    if (this.diagram.SelectedItem != null && hitTestService.ItemUnderMouse == null)
    {
        var selectionService = this.diagram.ServiceLocator.GetService<ISelectionService<IDiagramItem>>() as SelectionService;
        selectionService.ClearSelection();
    }
}

Please let me know if this helps.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ciro
Top achievements
Rank 1
answered on 30 Apr 2015, 01:43 PM

OK, this solution work for me.

 

I have another question about cursor on RadDiagram when I set ActiveTool = PanTool, in this case I want to use Arrow cursor for each operation.

I have tried to set the Cursor property of the RadDiagram but when I click with the mouse on the RadDiagram area my cursor is overwritten and I see the default cursor for PanTool.

However, in general I would like to use only the Arrow cursor.

 

How can I solve this?

 

Thank you

Ciro

0
Martin Ivanov
Telerik team
answered on 30 Apr 2015, 02:04 PM
Hello Ciro,

The diagram control uses a static DiagramCursors class to store and get its cursors. In order to replace the pan tool's cursor with the arrow cursor you can change the value of the DiagramCursors.Panning property before the InitializeComponent() call. 
public MainWindow()
{
    DiagramCursors.Panning = DiagramCursors.Pointer;
    InitializeComponent();
}

I hope this helps.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Diagram
Asked by
Ciro
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Ciro
Top achievements
Rank 1
Share this question
or