Beispiel #1
0
        private void OnTreeViewItemMouseDown(NMouseButtonEventArgs arg)
        {
            if (arg.Cancel || arg.Button != ENMouseButtons.Right)
            {
                return;
            }

            // Mark the event as handled
            arg.Cancel = true;

            // Get the right clicked tree view item
            NTreeViewItem item = (NTreeViewItem)arg.CurrentTargetNode;

            // Create the context menu
            NMenu     contextMenu         = new NMenu();
            NMenuItem copyLinkToClipboard = new NMenuItem("Copy link to clipboard");

            copyLinkToClipboard.Click += OnCopyLinkToClipboardClick;
            copyLinkToClipboard.Tag    = item.Tag;
            contextMenu.Items.Add(copyLinkToClipboard);

            // Show the context menu
            NSplitter splitter = (NSplitter)m_TreeView.ParentNode.ParentNode;
            double    x        = splitter.X + m_TreeView.X + arg.CurrentTargetPosition.X;
            double    y        = splitter.Y + m_TreeView.Y + item.YInRootItems + arg.CurrentTargetPosition.Y;

            NPopupWindow.OpenInContext(new NPopupWindow(contextMenu), m_TreeView, new NPoint(x, y));
        }
Beispiel #2
0
        private void OnTargetWidgetMouseDown(NMouseButtonEventArgs args)
        {
            if (args.Button != ENMouseButtons.Right)
            {
                return;
            }

            // Mark the event as handled
            args.Cancel = true;

            // Create and show the popup
            NWidget      popupContent = CreatePopupContent();
            NPopupWindow popupWindow  = new NPopupWindow(popupContent);

            NPopupWindow.OpenInContext(popupWindow, args.CurrentTargetNode, args.ScreenPosition);
        }
        private void OnTargetWidgetMouseDown(NMouseButtonEventArgs args)
        {
            NGroupBox ownerGroupBox = (NGroupBox)args.CurrentTargetNode.GetFirstAncestor(NGroupBox.NGroupBoxSchema);
            string    groupBoxTitle = ((NLabel)ownerGroupBox.Header.Content).Text;

            if ((groupBoxTitle.StartsWith("Left") && args.Button != ENMouseButtons.Left) ||
                (groupBoxTitle.StartsWith("Right") && args.Button != ENMouseButtons.Right))
            {
                return;
            }

            // Mark the event as handled
            args.Cancel = true;

            // Create and show the popup
            CreateMenuDelegate createMenuDelegate = (CreateMenuDelegate)args.CurrentTargetNode.Tag;
            NMenu contextMenu = createMenuDelegate();

            NPopupWindow.OpenInContext(new NPopupWindow(contextMenu), args.CurrentTargetNode, args.ScreenPosition);
        }