Right clicking mid way through dragging

11 posts, 0 answers
  1. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 08 Apr 2013 Link to this post

    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
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 08 Apr 2013 Link to this post

    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.

  3. DevCraft banner
  4. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 08 Apr 2013 Link to this post

    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
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 08 Apr 2013 Link to this post

    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.

  6. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 08 Apr 2013 Link to this post

    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
  7. Nick
    Admin
    Nick avatar
    593 posts

    Posted 09 Apr 2013 Link to this post

    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.

  8. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 09 Apr 2013 Link to this post

    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

  9. Nick
    Admin
    Nick avatar
    593 posts

    Posted 11 Apr 2013 Link to this post

    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.

  10. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 11 Apr 2013 Link to this post

    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


  11. Nick
    Admin
    Nick avatar
    593 posts

    Posted 11 Apr 2013 Link to this post

    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.

  12. Tracey
    Tracey avatar
    34 posts
    Member since:
    Feb 2011

    Posted 17 Apr 2013 Link to this post

    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...

Back to Top
DevCraft banner