Context Menu display creates unwanted OnClientMouseOut Event

2 posts, 1 answers
  1. OmegaMan
    OmegaMan avatar
    8 posts
    Member since:
    Mar 2012

    Posted 04 May 2012 Link to this post

    I have a context menu on a RadTreeView which appears when a user right clicks on a tree node and all works fine. I also have the OnClientMouseOver and OnClientMouseOut to create a popup RadWindow which which shows meta data about the current node; all works fine.

    But when I attempt to have the two processes worki together such as this scenario, it fails
    1. User's mouse enters the node space and the hover brings alive the RadWindow.
    2. User goes to right click the node (hasn't left the node's mouse out boundary)

    At that point the context menu starts displaying but the OnClientMouseOut is called which closes the meta window. Then the context window immediately dissapears and the mouse is now (hasn't moved) over the node's hover zone and the meta window is created a fresh and comes back up.

    The expected behavior is that the context window, as with the RadWindow which has been poped up, should exist together until the user chooses an action on the right click menu. At that point I could determine whether to close the RadWindow or not.

    Is it possible to not have the context operation generate a call to the OnMouseClose?


  2. Answer
    Bozhidar avatar
    1189 posts

    Posted 09 May 2012 Link to this post

    Hello William,

    The OnClientMouseOut event is bound directly to the mouse out event of the treenode, which is always called when the mouse cursor moves away from the node element. Since the showing of the context menu puts the context menu element "under" the mouse, this effectively means that the cursor is no longer over the node element, but over the context menu element and so the mouse out event is called.

    However there is a workaround to this issue that you can apply to your project. The OnClientContextMenuShowing event is raised before the OnClientMouseOut, and you can use it to set a flag that indicates whether you should close the window when the MouseOut event is raised. Here's some code to illustrate the approach:
    var shouldShowWindow = true;
    function onClientMouseOut(sender, args) {
        if (shouldShowWindow)
    function onClientContextMenuShowing(sender, args) {
        shouldShowWindow = false;

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top