Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
Right click on an item
posted

Is there any way to trigger if an item is right clicked? I would like to show my own context-menu in this case but I find no way to detect the right click. ItemClick does not work for the right mouse button. So I could use MouseClick, but I don't find a way to check if the mouse location is within an item or not..

Or is it preferred to modify the default context menu to fit my needs?

Thanks,
Stefan

Edit: I just found the function ItemFromPoint() which works fine. Now I only have problems when showing a context-menu for a group. GroupFromPoint() returns the group when I click on an empty place within a group and therefor the menu will be shown. I would like to restrict this to the group header only. When I use the GroupClick event it is only fired when I click on the group itself, this would be the desired way..

I just use the context menu to open a openfiledialog where the user can select an icon that is shown for the clicked item or group..

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    ItemFromPoint/GroupFromPoint don't tell you what part of the item/group was clicked, so you would have to manually hit test for the constituent part you are looking for:

    void ultraExplorerBar1_MouseDown(object sender, MouseEventArgs e)
    {
        UltraExplorerBar explorerBar = sender as UltraExplorerBar;
        UIElement controlElement = explorerBar.UIElement;
        UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null;

        while ( elementAtPoint != null )
        {
            UltraExplorerBarGroupHeaderUIElement headerElement = elementAtPoint as UltraExplorerBarGroupHeaderUIElement;

            if ( headerElement != null )
            {
                UltraExplorerBarGroup group = headerElement.Group;
            }

            elementAtPoint = elementAtPoint.Parent;
        }
    }

Children