mouseevent

Prevent mouse from leaving my form

孤街浪徒 提交于 2019-11-29 07:00:29
I've attached some MouseMove and MouseClick events to my program and next up is one of these: Get "global" mouse movement, so that I can read the mouse location even outside the form. Prevent my mouse from leaving the form in the first place. My project is a game so it'd be awesome to prevent the mouse leaving my form like most other games do (ofc. you can move it out if you switch focus with alt+tab fe.) and taking a look at answers to other questions asking for global mosue movement, they seem pretty messy for my needs. Is there an easy way to prevent my mouse from going outside my form's

Detect both left and right mouse click at the same time?

♀尐吖头ヾ 提交于 2019-11-29 04:44:19
I'm remaking windows Minesweeper (from XP) and something they had included was that if you click a number with as many flags as it's number with the left and right mouse button at the same time, it reveals every other hidden tile around that number. I'm having a hard time telling when both the Left and Right mouse buttons are pressed at the exact same time... I'm using a pair of bools, one for each button with the OnMouseDown and OnMouseUp events but if the 2 buttons are clicked at the exact same time (or really close), then only one MouseDown event goes off and the other does not... If you

How can I capture mouse events that occur outside of a (WPF) window?

廉价感情. 提交于 2019-11-29 04:03:02
I have a Window element that has WindowStyle="None" and AllowsTransparency="True" , therefore it has no title bar and supports transparency. I want the user to be able to move the Window to any position on the screen by left-clicking anywhere within the Window and dragging. The Window should drag along with the mouse as long as the left mouse button is pressed down. I was able to get this functionality to work with one exception: when the mouse moves outside of the Window (such as when the left mouse button was pressed down near the edge of the Window and the mouse is moved quicly), the Window

Fade in on mouse movement

旧时模样 提交于 2019-11-29 03:26:58
问题 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. 回答1: 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 + ')';

Microsoft Edge: onclick event stops working?

感情迁移 提交于 2019-11-29 03:08:37
I have strange problems with my (ASP.NET) web application in Microsoft Edge. At a certain point the onclick event stops working. All buttons on the page that respond to the onclick event stop working. On the same page I have some buttons that respond to the onmousedown event and they keep working. If I refresh the page, the problem is gone. There are no errors in the console. I do not have this problem with other browsers (including IE11 under Windows 10). Did any of you experience similar problems? This is not a complete answer, as it doesn't address why click events don't work, but I feel it

WPF MouseDown event not firing everywhere in a control

杀马特。学长 韩版系。学妹 提交于 2019-11-29 03:07:54
I am currently fighting against another WPF struggle, namely mouseEvents. I basically have a very simple control (a Border containing a Grid which itself has a few TextBlocks ). I am trying to achieve a simple behavior: Double click should turn the control into edit mode (which in fact hides the TextBlocks with TextBoxes bound to the same data. Nothing fancy, right? Well still, I'm struggling. The MouseDoubleClick linked to my UserControl just fires when I click in a control (like, clicking ON a textblock). If I click on an empty space between TextBlocks , nothing is fired. Not even MouseDown

Catching event when following a link

試著忘記壹切 提交于 2019-11-29 02:06:11
I am trying to track clicks on an external link (without using a "redirect page"). How can I capture an event when a user follows a link, regardless of whether the user: Left clicks on the link Right clicks on the link and open it in a new window Use the keyboard to activate the link Is there other ways to activate a link? The onClick event only applies to the first. If setting href="javascript:fireEventAndFollowLink()" the user will not be able to open the link in a new window (2), so this is not a sollution. Rob W A link can be triggered in some ways (assuming modern browsers, see foot note)

Is it possible to dispatchEvent() a mouse click to a <input type=text> element?

倖福魔咒の 提交于 2019-11-29 01:25:49
Basically I'm trying to dispatch a custom made mouse click event to a text input element using the following code (see this jsFiddle ): function simulateClick(id) { var clickEvent = document.createEvent("MouseEvents"); clickEvent.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); var element = document.getElementById(id); element.dispatchEvent(clickEvent); } When I run that code on a type="checkbox" element it works perfectly fine but it doesn't work at all when called on a type="text" element. Now here's the definition of initMouseEvent() on MDN:

TListView and mouse wheel scrolling

╄→尐↘猪︶ㄣ 提交于 2019-11-28 19:55:55
I have a TListView component in a form. It's quite long and I want user to able scroll it, if mouse is over the component and wheel is scrolled. I do not find any OnMouseWheel, OnMouseWheelDown or OnMouseWheelUp event for TListView object. How can I do that? Regards, evilone Here's my code to do this: type TMyListView = class(TListView) protected function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override; function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override; end; type TMouseWheelDirection = (mwdUp, mwdDown); function GenericMouseWheel(Handle:

How to measure the milliseconds between mousedown and mouseup?

こ雲淡風輕ζ 提交于 2019-11-28 19:16:39
Is there any way to measure the number of milliseconds between mouse press and release ? You could create a closure to share two variables, one to store the start time and other for the end time, then in the mouseup event, get the difference: (function () { var element = document.getElementById('element'), start, end; element.onmousedown = function () { start = +new Date(); // get unix-timestamp in milliseconds }; element.onmouseup = function () { end = +new Date(); var diff = end - start; // time difference in milliseconds }; })(); Check this working example . tl;dr answer Get the time