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

Right clicking mid way through dragging

10 Answers 50 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Tracey
Top achievements
Rank 1
Tracey asked on 08 Apr 2013, 11:41 AM
Hi

If you are dragging using the RadDragAndDropManager and you right click mid way through dragging then the Silverlight label appears and it interrupts the drag.

Is there anyway of handling the right click in this situation?

You can see this occurring on your drag and drop demos:
http://demos.telerik.com/silverlight/#DragAndDrop/FirstLook

Start dragging and item and midway through the drag click the right button as well..

Cheers

10 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 08 Apr 2013, 12:32 PM
Hello Tracey,

You can handle the MouseRightButtonDown event at application level and cancel it if there is a drag operation started.

Hope this helps! 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tracey
Top achievements
Rank 1
answered on 08 Apr 2013, 01:49 PM
I have tried that

I put the following in App.xaml
private void Application_Startup(object sender, StartupEventArgs e)
{
    Application.Current.RootVisual.MouseRightButtonDown += new  System.Windows.Input.MouseButtonEventHandler(RootVisual_MouseRightButtonDown);
}
private void RootVisual_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("RootVisual_MouseRightButtonDown");
        e.Handled = true;
}



The problem is I am already handling a Right Mouse Click event on the object that is being dragged so above doesn't get called.

But this right mouse click event on the object that I am dragging doesn't get called when I am in the midst of dragging it..

Any ideas?

Cheers
Tracey
0
Nick
Telerik team
answered on 08 Apr 2013, 01:57 PM
Hello Tracey,

Have you tried attaching the handler with handledEventsToo set to true?

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tracey
Top achievements
Rank 1
answered on 08 Apr 2013, 02:47 PM
That sounds like it should work - do you know how I would do this?

I can't do it via AddHandler because:
"you cannot use AddHandler to register for already-handled MouseRightButtonDown occurrences, because there is no public RoutedEvent identifier available for the event in Silverlight 4." msdn

Cheers
Tracey
0
Nick
Telerik team
answered on 09 Apr 2013, 11:37 AM
Hi Tracey,

May I ask you to share what version of our controls are you using?
Since Silverlight 4 doesn't offer the option to get handled mouse events, you can try canceling the context menu opening, to which I trust you can find many suggested approaches on the web, or update to Silverlight 5. 

All the best,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tracey
Top achievements
Rank 1
answered on 09 Apr 2013, 04:45 PM
I converted to Silverlight 5 and got the MouseRightButtonDown event working with handledEventsToo 

private void Application_Startup(object sender, StartupEventArgs e)
{
      Application.Current.RootVisual.AddHandler(UIElement.MouseRightButtonDownEvent, (MouseButtonEventHandler)RootVisual_MouseRightButtonDown, true);
}
private void RootVisual_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
      System.Diagnostics.Debug.WriteLine("RootVisual_MouseRightButtonDown");
      e.Handled = true;
}

However this didn't fire when you right clicked while dragging a node (nor did it fire when right clicking on radwindows for that matter but I guess that's to be expected).

All solutions regarding disabling the Silverlight context menu I have found are either to handle the right click event (which I would if I could get at it), disable it entirely with Javascript or simply do not work (http://www.dotnetspider.com/tutorials/Silverlight-Tutorial-319.aspx)

I guess what I want can't be done. Thanks for your help though, it's appreciated.

If anyone ever does comes up with a solution I would be very grateful. 

Cheers

0
Nick
Telerik team
answered on 11 Apr 2013, 11:10 AM
Hi Tracey,

Now it occurred to me that the Right Click may be received by the DragVisual object rather than the application itself. You can try subscribing to its MouseRightButtonDown event and cancel it there. 

Let me know how it goes! 

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tracey
Top achievements
Rank 1
answered on 11 Apr 2013, 01:56 PM
Would I have to switch from using RadDragAndDropManager to using DragDropManager to implement that?

This would be a problem as I use the arrow cue which I believe is no longer available with DragDropManager
see: http://www.telerik.com/community/forums/silverlight/drag-and-drop/telerik-update---drag-arrow-disappeared.aspx


0
Nick
Telerik team
answered on 11 Apr 2013, 02:02 PM
Hello Tracey,

You shouldn't have to update to DragDropManager to do that. You just need to subscribe for the MouseRightButtonDown event before you assign the DragCue in the DragQuery/Info event.

Nevertheless the RadDragAndDropManager is obsolete, and it will soon be removed, which means that if you plan to upgrade to a newer version of our controls, sooner or later you will have to migrate to DragDropmanager.

As for the DragArrow, you are correct. It is not available right out of the box, bit it can be easily implemented as shown here.

Hope this helps! 

All the best,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tracey
Top achievements
Rank 1
answered on 17 Apr 2013, 12:17 PM
I tried this

public void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    if (e.Options.Status == DragStatus.DragQuery)
    {
        // this gets called
        System.Diagnostics.Debug.WriteLine("e.Options.Status == DragStatus.DragQuery");
        Control ctrl = e.OriginalSource as Control;
        if (null != ctrl)
        {
            // and this gets called
            System.Diagnostics.Debug.WriteLine("null != ctrl");
            ctrl.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(ctrl_MouseRightButtonDown);
        }
        e.QueryResult = true;
        e.Handled = true;
    }
    if (e.Options.Status == DragStatus.DropSourceQuery)
    {
        e.QueryResult = true;
        e.Handled = true;
    }
}    
private void ctrl_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    // this does not get called
    System.Diagnostics.Debug.WriteLine(" ctrl_MouseRightButtonDown");
}

But the ctrl_MouseRightButtonDown event doesn't get called...

Tags
DragAndDrop
Asked by
Tracey
Top achievements
Rank 1
Answers by
Nick
Telerik team
Tracey
Top achievements
Rank 1
Share this question
or