mouseevent

Detecting middle mouse click event jQuery

狂风中的少年 提交于 2019-11-28 07:20:48
问题 I want to show a jQuery-UI dialog box as a popup when user clicks on left mouse button or the middle one. It works for left click (I get the alert box and after that the popup) but doesn't work for middle (neither alert box nor popup). What am I missing? $('a.external').live('click', function(e){ if( e.which <= 2 ) { e.preventDefault(); alert ("inside if"); } popUp.start(this); }); 回答1: Use mousedown or mouseup instead of click . And (unless you are using a very old version of jQuery) use .on

Visual C# Form right click button

試著忘記壹切 提交于 2019-11-28 07:11:48
问题 I am trying to make a minesweeper type game in visual c# and I want to have different things happen when I right click and left click a button, how do I do this? I have tried this code but it only registers left clicks: private void button1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { MessageBox.Show("Left"); } if (e.Button == System.Windows.Forms.MouseButtons.Right) { MessageBox.Show("Right"); } } 回答1: You will have to use the

How to prevent JLabel positions from resetting?

▼魔方 西西 提交于 2019-11-28 07:07:11
问题 I have a JPanel that contains 11 JLabels, each of them registered with a MouseMotionListener like so (generated by Netbeans): label1.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseMotionEvent evt){ label1MouseDragged(evt); } and the individual labelXMouseDragged methods contain (for example): label1.setLocation(label1.getParent().getMousePosition()); This Panel lives inside another Panel alongside various other controls. I find that I can drag my labels just

Jquery / JS bind “paste” event handler to input textbox

删除回忆录丶 提交于 2019-11-28 06:32:14
Allright, SO i have an input box and I need to do things everytime it changes, I am having trouble doing it for mouse paste. Here is the code I have $("#attack-navy"+unit.ID+"-number").bind('paste', function(){ alert("paste detected"); $("#attack-max-capacity").text(getMaxCapacity()); }); the getMaxCapacity() function return number entered * 30 for now; Here is the scenario when 1: I paste 3, it will not change (i still see the alert) 2: Then when i paste 5, it will be 90(3 * 30) 3: Then if i paste 10 it will be 150(5 * 30), and so on. I think its doing the handler before the paste actually

How i can simulate a double mouse click on window ( i khow handle) on x, y coordinate, using SendInput?

点点圈 提交于 2019-11-28 06:05:01
How i can simulate a double mouse click on window ( i know handle of this window) on x, y coordinate, using SendInput? void DoubleClick(int x, int y) { const double XSCALEFACTOR = 65535 / (GetSystemMetrics(SM_CXSCREEN) - 1); const double YSCALEFACTOR = 65535 / (GetSystemMetrics(SM_CYSCREEN) - 1); POINT cursorPos; GetCursorPos(&cursorPos); double cx = cursorPos.x * XSCALEFACTOR; double cy = cursorPos.y * YSCALEFACTOR; double nx = x * XSCALEFACTOR; double ny = y * YSCALEFACTOR; INPUT Input={0}; Input.type = INPUT_MOUSE; Input.mi.dx = (LONG)nx; Input.mi.dy = (LONG)ny; Input.mi.dwFlags =

Styling d3´s tooltip

天涯浪子 提交于 2019-11-28 05:20:49
问题 I implement a tooltip over circles placed through d3 on a leafletmap like this: var tooltip = d3.select("body") .append("div") .attr("id", "mytooltip") .style("position", "absolute") .style("z-index", "10") .style("visibility", "hidden") .text("a simple tooltip"); feature.on("mouseover",function(d) { d3.select(this) .transition() .ease("elastic") .duration(500) .attr('r', function (d){ return (d.properties.xy * 5) .style("stroke", "black") d3.select("#mytooltip") .style("visibility", "visible

How do you Hover in ReactJS? - onMouseLeave not registered during fast hover over

会有一股神秘感。 提交于 2019-11-28 04:48:39
How can you achieve either a hover event or active event in ReactJS when you do inline styling? I've found that the onMouseEnter, onMouseLeave approach is buggy, so hoping there is another way to do it. Specifically, if you mouse over a component very quickly, only the onMouseEnter event is registered. The onMouseLeave never fires, and thus can't update state... leaving the component to appear as if it still is being hovered over. I've noticed the same thing if you try and mimic the ":active" css pseudo-class. If you click really fast, only the onMouseDown event will register. The onMouseUp

WPF combining MouseDown and TouchDown to same event

十年热恋 提交于 2019-11-28 04:20:32
问题 I am developing an app which will be used on a laptop with touch screen. Hence MouseDown events are essentially doing the same action, how should this be done. The code I have written something like this - XAML <Button MouseDown="Button_OnMouseDown" TouchDown="Button_OnTouchDown"/> C# private void Button_OnMouseDown(object sender, MouseButtonEventArgs e) { Action(); } private void Button_OnTouchDown(object sender, TouchEventArgs e) { Action(); } private void Action() Is there a better way to

Google.Maps.Event settings - Va versus Xa

时光总嘲笑我的痴心妄想 提交于 2019-11-28 02:27:40
I am using an Event Listener that refer to the relatedTarget variable for Firefox or the toElement variable for Chrome and IE. But since I made that part of the code the parent variable changed. Why? For example, before today I needed to use evt.Va.toElement to refer to the toElement variable but since this morning I need to use evt.Xa.toElement . Why did it change? google.maps.event.addListener(polygon,"mouseout",function(evt){ // Mouseout if(evt.Xa.toElement){ // For Chrome and IE if(evt.Xa.toElement.id != "idName"){ // Do something } } else { // Do something else } } Is there a way to use

Python Tkinter: Tree selection

我与影子孤独终老i 提交于 2019-11-28 01:40:17
问题 I have created 2 trees with idlelib.TreeWidget in Canvas, left and right. I am also able to print out the name of a tree node if double-clicked, but what I need is double-clicking one tree node will make a certain tree node visible and selected. I have a simple example here. If you double click "level1" on the left hand side, "ccc" on the right hand side should be visible and automatically selected. How do you do that? Please run the following code: from Tkinter import Tk, Frame, BOTH, Canvas