mouseevent

Mouse Click Location On A PictureBox Not Detected Within Label

好久不见. 提交于 2019-12-25 01:54:06
问题 I have a Form that contains only 2 things, a PictureBox and a Label . I added a mouse click event handler to the picture box. this.pictureBox1.MouseClick += picture_MouseClick; Inside the handler I need to check if the location of the mouse click is within the bounds of the label. To do this, I am using the mouse event location and checking to see whether that location is within the bounds of the label. private void picture_MouseClick(object sender, MouseEventArgs e) { if (label1.Bounds

How to get mouse position in float or double with exact resolution?

被刻印的时光 ゝ 提交于 2019-12-25 01:46:04
问题 I need to take the mouse click position in float or double, how can I do that?In mouse listener, I take the point like this, e.getPoint(); but Point object's x and y values are integer, I need position in float or double. Any help will be appreciated. Edit I need exact resolution. 回答1: getPoint() gives you integer values because that is the precision in which coordinates are specified. See http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Point.html. Why do you need floating-point values? Edit

Making a Movieclip which is set as mask clickable and respond to MouseEvents

别等时光非礼了梦想. 提交于 2019-12-25 01:36:59
问题 I am trying to do panning of a movieclip I have two movieclips on stage. canvasPanel_mc and mask_mc. The former is the maskee for the mask (mask_mc). Inside mask_mc there is a movieclip dragCanvas_mc. The alpha of dragCanvas_mc is set to zero. This is code that I am using: mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrag); mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_OUT,onStopDrag); mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_UP,onStopDrag);

Silverlight Mouse Events: MouseEnter and MouseLeave conflicts

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 01:14:06
问题 I have a collection of buttons in a grid. For each one of these buttons, I want to handle the MouseEnter and MouseLeave events to animate the height of the button (and do some other interesting stuff). It all works good until I start moving my mouse too fast over and off the buttons which eventually cause the events to take place at before the other is complete. What's the best way of making sure the events wait for eachother before being triggered? UPDATE: Going by x0r's advice, I refactored

Is there simple way to detect keyboard and mouse button being pressed and held in Java without application focus?

落花浮王杯 提交于 2019-12-24 21:51:06
问题 I'm trying to write quite simple program in Java - when user click left mouse button it will autoclick until released, but only if toggled before with keyboard key. I have no problem with this autofire part, but I dont know how to detect keyboard press, and mouse button press when my aplication doesn't have focus. Is there some simply way to do it? 回答1: On a side note - Are you creating macro for game? You can download jNativeHook https://code.google.com/p/jnativehook/ and hook global

attaching listeners to body doesn't work?

 ̄綄美尐妖づ 提交于 2019-12-24 19:09:29
问题 I can't figure out why this piece of code isn't working: <!DOCTYPE html> <html><head></head><body onload=" document.body.addEventListener('mousedown',function(e){ alert(123); },false); "></body></html> There isn't even any error whatsoever.. it just does nothing. amazingly if i change 'mousedown' to 'keydown' it works <!DOCTYPE html> <html><head></head><body onload=" document.body.addEventListener('keydown',function(e){ alert(123); },false); "></body></html> (I'm using chrome btw) 回答1: The

Why isn't mouselistener working?

狂风中的少年 提交于 2019-12-24 14:08:04
问题 Here's the code. It prints out the mouse location when it's in the panel but not the JTextArea. I added the mouse listener to the text area as well? The problem is that the coordinates are not consistent throughout the JFrame. Is there a way to just have one mouselistener that covers the entire jframe? Is there a way to disable the mouse listener in the textarea? import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt

Position of click within div

只谈情不闲聊 提交于 2019-12-24 12:49:44
问题 I'm trying to get the position of a click inside a div so that when I position a window as the mouse drag moves it, the mouse cursor will be exactly on the spot (relative to the moving window) where the initial click occurred. Here's the window: <div id="PopUp" class="Popup"> <div id="PopUpTitleBar"><img class="xOut" onclick="ClosePopUp();" src="/images/xOut.png"></div> <div class="InnerPopup"> <!-- <p>Here is the body of a pop up element.</p> --> <p id="PopUpBody"></p> </div> </div> And I

How to use requestAnimationFrame in mousemove event?

China☆狼群 提交于 2019-12-24 12:32:16
问题 In my SVG based web application, a user can select a large number of shapes (even 800 or more) & move them about on the screen, which as one can imagine severely impacts the framerate. After reading the merits of requestAnimationFrame , I have been working since yesterday trying to incorporate it into my mousemove function, with the hope that by using a combination of throttling & requestAnimationFrame , I can get to a smooth framerate. Here is the jsFiddle in which I am moving 600 svg shapes

mousePressed won't respond on JPanel

旧城冷巷雨未停 提交于 2019-12-24 12:13:47
问题 I am trying to write a code that when the user clicks once, a little dot shows up, twice a line forms from the first and second clicks, and third forms a triangle out of all the clicks, and clicking again restarts with a dot. Currently I can get my JFrame and JPanel to open, but clicking does nothing. I added in a System.out.print command just to see if my mousePressed method ever ran, but it never does. Here is my code currently: import java.awt.Graphics; import java.awt.Point; import java