mouseevent

Change mouseListener while mouse is pressed

旧巷老猫 提交于 2019-11-29 17:08:32
I'm working on a game in Java and have the following challenge. I have 2 JPanels and need to visually drag shapes from one JPanel to another. I've got this working using the GlassPane from the JFrame . When I press the mouse to drag a shape, the GlassPane activates and transfers the shape to the glassPane. Because of this you need to transfer the mousePressed state from the JPanels mouseAdapter to the glassPanes mouseAdapter . I solved this by using the Robot Class which simulates another mousePressed event after the glassPane has been acivated. Now here comes the problem, this workaround only

Routing Mouse Events through a Sprite in Actionscript 3

不打扰是莪最后的温柔 提交于 2019-11-29 16:02:06
In a pure Actionscript 3 project, I have a sprite that overlaps another sprite. The lower sprite normally handles mouse clicks. The lower sprite no longer processes mouse events when it is overlapped by the higher sprite. I understand that this is normal behavior. I would like the lower sprite to handle mouse events when it is overlapped. (In my particular instance, the higher sprite is just a decorative piece; it has no normal mouse interactivity anyway.) Is this possible? Is there a way to route mouse events through the higher sprite? I found a short, dated discussion about my problem here:

How can I raise a mouse event in WPF / C# with specific coordinates?

喜夏-厌秋 提交于 2019-11-29 14:37:12
问题 I'd like to raise a mouse event (a click, mousedown, or mouseup) by taking a user's click anywhere in a WPF window and translating it by a known difference, e.g. click at x,y, raise the click event at x+100, y+100. The underlying problem is that there's a display monitor that physically moves relative to an overlaying touch screen. Rather than recalibrating the touchscreen with every move, I'd like to add the translation offset to the click event. I've looked at the Win32 API for mouse_event

MouseListener on JFrame

倾然丶 夕夏残阳落幕 提交于 2019-11-29 14:16:56
I want to be notified of mouse events (specifically the mouse entered and exited events) on my JFrame. But when i add a mouselistener to it i get the events on the borders of the frame not the entire frame with it's contents. Any ideas as to why? EDIT : Or at least do you have an alternative? I want a "gloabal" way to catch mouse events on the JFrame. Maybe a mouselistener is not the answer. You can get all events and check if their source is a component in the JFrame. See Toolkit.addAWTEventListener There is an invisible component that overlays the whole GUI, the "glass pane". You can attach

Visual C# Form right click button

懵懂的女人 提交于 2019-11-29 13:34:49
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"); } } You will have to use the MouseUp or MouseDown event instead of the Click event to capture right click. Just try with button1_MouseDown

Detecting middle mouse click event jQuery

廉价感情. 提交于 2019-11-29 13:27:06
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); }); Use mousedown or mouseup instead of click . And (unless you are using a very old version of jQuery) use .on() instead of .live() : $(document).on("mousedown", "a.external", function(e) { if( e.which <= 2 ) { e

How to prevent JLabel positions from resetting?

我们两清 提交于 2019-11-29 12:58:05
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 fine inside the panel (I had my methods correctly checking for bounds, but I have left them like the

Passing the click event on one jPanel to another JPanel

五迷三道 提交于 2019-11-29 12:55:56
I have one outer panel, in the outer panel I have another jPanel placed on it. if i do a right click on the inner panel, outer panel's right click action should happen. if i do left click on the inner panel, its own inner panel's click action should happen. Is it possible to pass click event from one panel to another panel? There are a number issues you need to resolve for this to work. The first is understanding that a mouse event is contextual to the component that created it, in particular, the location information. The click point is the offset from the source components x/y position

Styling d3´s tooltip

為{幸葍}努か 提交于 2019-11-29 12:08:32
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") .text(d.properties.xy1 + " " + d.properties.xy2) }); feature.on("mousemove", function() { return

Disable TreeItem's default expand/collapse on double click JavaFX 2.2

牧云@^-^@ 提交于 2019-11-29 11:19:55
I am working on a JavaFX 2.2 project and i want to set custom handling of the mouse (double) click event on a TreeItem. Using treeview.setOnMouseClicked i fire my code without errors but the problem is that the TreeItem, on every mouse double click, it toggles between expanded and collapsed. I suppose that this is the default behavior, but how i disable it?? I had the same issue and solved it in time using EventDispatcher . class TreeMouseEventDispatcher implements EventDispatcher { private final EventDispatcher originalDispatcher; public TreeMouseEventDispatcher(EventDispatcher