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

Context Menu display creates unwanted OnClientMouseOut Event

1 Answer 32 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
OmegaMan
Top achievements
Rank 1
OmegaMan asked on 04 May 2012, 10:13 PM
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?

advTHANKSance

1 Answer, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 09 May 2012, 08:19 AM
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)
        alert('window');
}
 
function onClientContextMenuShowing(sender, args) {
    shouldShowWindow = false;
}

 
All the best,
Bozhidar
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.
Tags
TreeView
Asked by
OmegaMan
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or