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

Disabling click-to-open on right click only.

3 Answers 43 Views
Splitter
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 11 Aug 2011, 08:11 PM
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?

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 17 Aug 2011, 07:44 AM
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.

0
Sean
Top achievements
Rank 2
answered on 17 Aug 2011, 05:32 PM
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
0
Dobromir
Telerik team
answered on 22 Aug 2011, 04:14 PM
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 >>

Tags
Splitter
Asked by
Sean
Top achievements
Rank 2
Answers by
Dobromir
Telerik team
Sean
Top achievements
Rank 2
Share this question
or