Disabling click-to-open on right click only.

4 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 11 Aug 2011 Link to this post

    Hi Telerik,

    I have a RadSlidingZone which has ClickToOpen enabled. I would like to cancel the opening event (or not fire it) when the user right-clicks. It's weird to have a context menu open with the sliding zone opening up, too.

    How can I achieve this? Is it implicitly supported, or do I need to capture the click event and figure out if its a right click in JS?
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 17 Aug 2011 Link to this post

    Hi Sean,

    RadSlidingPane does not offer built-in functionality to separate mouse button's clicks and, unfortunately, at present the ClientBeforeExpand event of the sliding pane does not expose the DOM event and it is not possible to cancel it if right mouse button is clicked. I have logged this into our database and we will do out best to handle this scenario for one of the upcoming releases.

    For the time being you can use the following approach to prevent expanding of a sliding pane on right mouse click:
    <script type="text/javascript">
        var oldMouseDownHandler = Telerik.Web.UI.RadSlidingZone._paneTab_OnMouseDown;
     
        Telerik.Web.UI.RadSlidingZone.prototype._paneTab_OnMouseDown = function (e)
        {
            if (isRightClick(e)) return;
     
            oldMouseDownHandler(e);
        }
     
        function isRightClick(e)
        {
            var result = false;
            if (e.which)
            {
                if (e.which == 2)
                {
                    result = true;
                }
            }
            else if (e.button)
            {
                if (e.button == 2)
                {
                    result = true;
                }
            }
     
            return result;
        }
    </script>


    All the best,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 17 Aug 2011 Link to this post

    Hi Dobromir,

    Thank you for your response. The provided code is yielding the following error: Uncaught TypeError: Property 'oldMouseDownHandler' of object [object DOMWindow] is not a function
    ...which is curious considering in order for it to get inside that function the OnMouseDown event has to be defined. I played around with the code a bit, trying out jQuery pre-fixes on the event, changing the oldMouseDownHandler assignment to include prototype, terminating the function declarations with semi-colons. No go! Unfortunately, JavaScript isn't exactly my strongest suit. Any advice?

    Thanks

    Sean
  5. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 22 Aug 2011 Link to this post

    Hi Sean,

    Please accept my sincere apologies for providing incorrect code snippet. Here is the correct one:
    var oldMouseDownHandler = Telerik.Web.UI.RadSlidingZone.prototype._paneTab_OnMouseDown;
    Telerik.Web.UI.RadSlidingZone.prototype._paneTab_OnMouseDown = function (e)
    {
        if (isRightClick(e)) return;
     
        oldMouseDownHandler.call(this, e);
    }
     
    function isRightClick(e)
    {
        var result = false;
        if (e.which)
        {
            if (e.which == 2)
            {
                result = true;
            }
        }
        else if (e.button)
        {
            if (e.button == 2)
            {
                result = true;
            }
        }
     
        return result;
    }


    Best wishes,
    Dobromir
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top