How to handle onContextItemSelected in a multi fragment activity?

I’ll post an answer even though you found a workaround because I just dealt with a similar issue. When you inflate the context menu for a specific fragment, assign each menu item a groupId that is unique to the fragment. Then test for the groupId in ‘onContextItemSelected.’ For Example: public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo … Read more

Find node clicked under context menu

You can add a mouse click event to the TreeView, then select the correct node using GetNodeAt given the mouse coordinates provided by the MouseEventArgs. void treeView1MouseUp(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Right) { // Select the clicked node treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y); if(treeView1.SelectedNode != null) { myContextMenuStrip.Show(treeView1, e.Location); } } }

Configuring jstree right-click contextmenu for different node types

The contextmenu plugin already has support for this. From the documentation you linked to: items: Expects an object or a function, which should return an object. If a function is used it fired in the tree’s context and receives one argument – the node that was right clicked. So rather than give contextmenu a hard-coded … Read more

Select TreeView Node on right click before displaying ContextMenu

Depending on the way the tree was populated, the sender and the e.Source values may vary. One of the possible solutions is to use e.OriginalSource and find TreeViewItem using the VisualTreeHelper: private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); if (treeViewItem != null) { treeViewItem.Focus(); e.Handled = true; } } … Read more

How to create context menu for RecyclerView

Thanks for the info and comments. I was able to achieve ContextMenu for items in Recyclerview. Here is what I did in Fragment’s onViewCreated method or Activity’s onCreate method: registerForContextMenu(mRecyclerView); Then in Adapter add private int position; public int getPosition() { return position; } public void setPosition(int position) { this.position = position; } make the … Read more

How do I create a right click context menu in Java Swing?

You are probably manually calling setVisible(true) on the menu. That can cause some nasty buggy behavior in the menu. The show(Component, int x, int x) method handles all of the things you need to happen, (Highlighting things on mouseover and closing the popup when necessary) where using setVisible(true) just shows the menu without adding any … Read more

right click context menu for datagridview

You can use the CellMouseEnter and CellMouseLeave to track the row number that the mouse is currently hovering over. Then use a ContextMenu object to display you popup menu, customised for the current row. Here’s a quick and dirty example of what I mean… private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) … Read more

Making custom right-click context menus for my web-app

I know this question is very old, but just came up with the same problem and solved it myself, so I’m answering in case anyone finds this through google as I did. I based my solution on @Andrew’s one, but basically modified everything afterwards. EDIT: seeing how popular this has been lately, I decided to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)