mouseevent

Fade in on mouse movement

风流意气都作罢 提交于 2019-11-30 05:34:45
How do I fade in div content on first mouse movement, like on google.com, using JavaScript? I don't want it to fade out again. galambalazs Code: ( See it in action ) // attach event handler document.body.onmousemove = function(){ fadeIn( this, 1000 ); // 1000ms -> 1s this.onmousemove = null; // remove to only fade in once! }; // sets the opacity of an element (x-browser) function setOpacity( obj, value ) { if ( obj ) { obj.style.opacity = value / 100; obj.style.filter = 'alpha(opacity=' + value + ')'; obj.style.zoom = 1; } } // makes an element to fade in function fadeIn( dom, interval, delay

Android: Tracking mouse pointer movement

落花浮王杯 提交于 2019-11-30 04:42:45
问题 Assuming that I am using a generic mouse, is it possible to track the X and Y coordinates of the mouse pointer in android? 回答1: You need a OnGenericMotionListener : OnGenericMotion(...., MotionEvent me) { if (me.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) { } api 14+ needed [confirmed] Found me a tablet with usb mouse and can confirm this works for mouse movement. You WILL get flooded with messages, so simple operations or sleeping should be considered. 回答2: The docs to ACTION_MOVE lead me

capture mouse position on setInterval() in Javascript

匆匆过客 提交于 2019-11-30 04:22:28
问题 I have a function in javascript that moves one div depending on the mouse position. This function is set on a setInterval() function and executed every second. I need to capture the mouse position like this: function mousemov() { document.getElementById("myDiv").style.left = Event.clientX; //don't work } window.onload = function() { setInterval("mousemov()",1000); } Ps: I cannot use the mousemove event because the function must be executed even if the mouse is stopped. Thanks for helps! 回答1:

identifying double click in java

三世轮回 提交于 2019-11-30 04:11:23
I want to know how can we perform action when mouse is double clicked in a component. public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { System.out.println("double clicked"); } } Assuming you mean in Swing, assign a MouseListener to your Component: addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent e){ if(e.getClickCount()==2){ // your code here } } }); Reference: Java Tutorial: How to write a Mouse Listener davidxxx The e.getClickCount()==2 is not enough if you want to allow your users to do multiple double clicks in a short delay.

How to simulate mouse click from Mac App to other Application

别说谁变了你拦得住时间么 提交于 2019-11-30 01:10:09
问题 I am trying to simulate mouse click on iphone simulator from macos App for that I am using CGEvents . the process id is 33554 for iPhone simulator let point = CGPoint(x: 500 , y:300) let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left) let eventMouseUp = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left) eventMouseDown?.postToPid(33554) eventMouseUp?.postToPid(33554)

Trigger 'dummy' mouse wheel event

别来无恙 提交于 2019-11-30 00:31:04
问题 Is there a way to trigger a scroll wheel event with an arbitrary delta. Just like jQuery does with 'click' like: $('#selector').trigger('click'); I need something like that just with an scrollwheel like: $('#selector').trigger('DOMMouseScroll',{delta: -650}); //or mousewheel for other browsers I can't do anything like 'fake it' with css trickery, I need to trigger the actual native (or as close as possible) event. Thankyou! 回答1: You need to use jQuery.Event For example: // Create a new jQuery

Simulate mouse on Mac

為{幸葍}努か 提交于 2019-11-29 23:42:49
问题 I have a virtual trackpad on my iPhone and to move my mouse I'm using : CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, CGPointMake(((float)aD.msg)+location.x, ((float)aD.msg2)+location.y)); It's working well but this not a real mouse because when I put my mouse on my hidden dock, this one doesn't display it self. I don't understand why. More over I tried to simulate mouse click with : case MOUSECLICK: [self postMouseEventWithButton:0 withType:kCGEventLeftMouseDown andPoint

In React, onMouseEnter or hover is not working as expected

随声附和 提交于 2019-11-29 19:56:40
问题 I have one image with opacity = 1 at the beginning. When mouse enters the image, change opacity = 0.5 . When mouse leaves the image, change the opacity back. here is one code: mouseEnter() { console.log('mouse enter') const classname = '.' + this.props.post.code document.querySelector(classname).classList.add('image-hover-opacity') } mouseLeave() { console.log('mouse leave') const classname = '.' + this.props.post.code document.querySelector(classname).classList.remove('image-hover-opacity')

How to detect mouse movement over node while button is pressed?

烂漫一生 提交于 2019-11-29 19:05:27
问题 Problem You can add an event listener to a node which detects mouse movement over it. This doesn't work if a mouse button was pressed before you moved over the node. Question Does anyone know how to detect mouse movement while the button is pressed? So far I've only found a solution by using the MOUSE_DRAGGED event and then instead of using getSource() using getPickResult() and evaluating the PickResult data. Here's the code including Uluk's solution. The old and new solution are switchable

Html5/Js canvas capturing mouse coords when it moves fast

安稳与你 提交于 2019-11-29 18:17:15
I have a canvas where I draw a curve. onmouseup lines are drawn based on that curve and connecting specific x-points for it. The problem is that if the mouse is moved fast , not all of its points are captured . var canvas; var ctx; function drawCanvas(popup) { var flag = false; canvas = document.querySelector(popup + " #canvasG"); ctx = canvas.getContext('2d'); var sketch = document.querySelector(popup + " #canvasD"); var sketch_style = getComputedStyle(sketch); canvas.width = parseInt(sketch_style.getPropertyValue('width')); canvas.height = parseInt(sketch_style.getPropertyValue('height')); /