Jquery/JS prevent right click menu in browsers
You can disable the right click by appending oncontextmenu=”return false;” to your body tag. <body oncontextmenu=”return false;”>
You can disable the right click by appending oncontextmenu=”return false;” to your body tag. <body oncontextmenu=”return false;”>
I finally solved it: In Visual Studio, create a ContextMenuStrip with an item called “DeleteRow” Then at the DataGridView link the ContextMenuStrip Using the code below helped me getting it work. this.MyDataGridView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MyDataGridView_MouseDown); this.DeleteRow.Click += new System.EventHandler(this.DeleteRow_Click); Here is the cool part private void MyDataGridView_MouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Right) { … Read more
For Minesweeper game you have look for 1) JToggleButton 2) add Icon to JToggleButton methods JToggleButton#setIcon(); JToggleButton#setSelectedIcon(); JToggleButton#setDisabledIcon(); 3) add MouseListener to JToggleButton 4) override mouseClicked with method SwingUtilities.isRightMouseButton() inside result could be from code import java.awt.Insets; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.Icon; import javax.swing.JFrame; import javax.swing.JToggleButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class MyToggleButton extends … Read more
If you’re looking for a quick and dirty workaround, you can create a shortcut to your executable in ‘%AppData%\Microsoft\Windows\SendTo’ Now you can select a bunch of files, right click, select Send To, and your application. This will pass all the selected files as individual command line options to one instance of your application… keep in … Read more
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
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
Answering your question – use contextmenu event, like below: if (document.addEventListener) { document.addEventListener(‘contextmenu’, function(e) { alert(“You’ve tried to open context menu”); //here you draw your own menu e.preventDefault(); }, false); } else { document.attachEvent(‘oncontextmenu’, function() { alert(“You’ve tried to open context menu”); window.event.returnValue = false; }); } <body> Lorem ipsum… </body> But you should ask … Read more
As of jQuery version 1.1.3, event.which normalizes event.keyCode and event.charCode so you don’t have to worry about browser compatibility issues. Documentation on event.which event.which will give 1, 2 or 3 for left, middle and right mouse buttons respectively so: $(‘#element’).mousedown(function(event) { switch (event.which) { case 1: alert(‘Left Mouse button pressed.’); break; case 2: alert(‘Middle Mouse … Read more