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

Dragging shapes

1 Answer 59 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Jesper
Top achievements
Rank 2
Jesper asked on 27 Aug 2014, 12:43 PM
Hi Guys,

A while back we were in contact with you regarding dragging shapes without they change position. TicketID: 662635.

We implemented the solution you guys suggested.

Now we have discovered a bug regarding the way we drag shapes.

The problem is because we set Handled = true in DragPreview, when dragged shape is dropped outside the diagram, the drag operation is never ended.

Issue here is we implemented a DragAdorner that follows the cursor, and when it re-enters the diagram the drag operation is still active. Even though the mouse button is not pressed. The issues also exists in the sample projects from the support ticket. (No dragTemple, but changed cursor)

Is there a way we can end the drag operation, when MouseLeftButtonUp occurs outside diagram.

/Anders

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 29 Aug 2014, 02:25 PM
Hello Jesper,

The reported behavior is caused by the WPF framework and is not directly related to the RadDiagramControl itself. As I can see in the project that my colleague Peter provided you the drop logic and the canceling of the drag operation are executed in the LeftMouseButtonUp event. This event is never called because when you mouse up outside the window the mouse is not captured by default and the window doesn't know that the mouse is up. 

In order to resolve this you can capture the mouse when you start the drag operation and release it again when the drop is executed.

private void diagram_PreviewDrag_1(object sender, DragRoutedEventArgs e)
{
    .....
    this.diagram.CaptureMouse();
}
 
void diagram_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    ....
    this.diagram.ReleaseMouseCapture();
}

Please let me know if this helps.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Diagram
Asked by
Jesper
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
Share this question
or