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

Hiding context menu

2 Answers 59 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Janni
Top achievements
Rank 1
Janni asked on 05 Sep 2008, 10:02 AM
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 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 08 Sep 2008, 12:13 PM
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.
0
Veselin Vasilev
Telerik team
answered on 23 Oct 2008, 11:29 AM
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.
Tags
Menu
Asked by
Janni
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or