Hiding context menu

3 posts, 0 answers
  1. Janni
    Janni avatar
    2 posts
    Member since:
    Jun 2008

    Posted 05 Sep 2008 Link to this post

    Hi,

    I found an example in your documentation that would hide the context menu when you move the mouse out of the context menu. I can't get it to work though... It hides whenever the mouse is moved outside a single item even if it still is within the context menu.

    The example I used is as follows:

    function OnClientMouseOutHandler(sender, eventArgs)
    {
       var destinationElement = eventArgs.get_domEvent().rawEvent.toElement || eventArgs.get_domEvent().rawEvent.relatedTarget;
       var menuDiv
    = $get("<%= RadContextMenu1.ClientID %>");
       
       
    while(destinationElement && destinationElement != menuDiv)
       {
           
    destinationElement = destinationElement.parentNode;
       }
       
    if (destinationElement == menuDiv)
       {
           
    //mouse is within the menu       
           
    return;
       }   
       
    //mouse is out of the menu
       
    sender.hide();        


    /Janni
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 08 Sep 2008 Link to this post

    Hi Janni,

    It seems that now the $get("<%= RadContextMenu1.ClientID %>") does not return the proper Div element.
    We will check this and try to fix it as soon as possible.

    I have updated your Telerik Points for your involvement.

    Regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 23 Oct 2008 Link to this post

    Hello Janni,

    Subscribe to the OnClientShowing event of the context menu and define its event handler as follows:

    <script type="text/javascript"
    function OnClientShowingHandler(sender, args) 
        var element = sender.get_contextMenuElement(); 
        var handler = function(e) 
        { 
            var relatedTarget = e.rawEvent.relatedTarget || e.rawEvent.toElement; 
            if (!$telerik.isDescendantOrSelf(element, relatedTarget)) 
            { 
                sender.hide(); 
                $removeHandler(element, "mouseout", handler); 
                return
            } 
        }; 
      
        $addHandler(element, "mouseout", handler); 
    </script> 

    I hope this helps.

    Sincerely yours,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top