mousedown

Automatic drag and drop with a click

纵然是瞬间 提交于 2021-02-10 16:10:25
问题 I'm looking for an automatic drag and dropper. First, when I click anywhere on the screen, get coordinates, then drag and drop an element with the ID of "ball". using jQuery OR javascript. I coded a similar script to what I want, but this script got patched when the website's client got updated. This one automatically dragged and dropped when I pressed key 1 (keycode 49), (function () { 'use strict'; var mouseX = 0; var mouseY = 0; var invName = ''; var timer = 0; document.body

NSLayoutManager returns incorrect glyphIndex for mousePosition in NSTextView

半世苍凉 提交于 2020-08-09 08:08:37
问题 I have an NSTextView subclass as the right item in an NSSplitViewController , the left panel is an NSOutlineView . To process mouse clicks while the command key is pressed in the text view, I added the following to find the glyph that is under the mouse: override func mouseDown(with event: NSEvent) { guard let lm = self.layoutManager, let tc = self.textContainer else { return } let localMousePosition = convert(event.locationInWindow, to: nil) var partial = CGFloat(1.0) let glyphIndex = lm

WPF Mouse Down Event won't fire

吃可爱长大的小学妹 提交于 2020-02-01 00:42:07
问题 I must be doing something stupid here but I cant get a MouseDown event to fire when I am clicking on the UserControl. Driving me Mad. Here's the XAML for the UserControl: <UserControl x:Name="cusTextBox" x:Class="StoryboardTool.CustomTextBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

mousemove event updating only once after mousedown

自闭症网瘾萝莉.ら 提交于 2020-01-15 05:42:06
问题 I'm having problems with mousemove in jquery. I want to check the coordinates of the mouse pointer AFTER a mousedown event AND a mousemove event, but it updates only once and the result is only the coordinates at the moment of the mousedown event. I really need some advices, thanks :) I post only a short extract of my original code here: P.S. I tried to use "$(document).ready(function(){", but without success. <!DOCTYPE html> <head> <title>jQuery Test</title> <script src="//code.jquery.com

how to prevent focus event in IE when mousedown happens

99封情书 提交于 2020-01-10 03:01:07
问题 event.preventDefault(); return false; event.stopPropagation(); any of them can prevent focus event from happening when I trigger a mousedown event in Firefox and chrome, but it failed in IE.In fact,chrome has another problem. when mousedowning, :hover css is not working. ` <input type="text" id="name"> <div id="suggest"> <div>mark</div> <div>sam</div> <div>john</div> </div> $("#name").focus(suggest.show).blur(suggest.hide); ` what I expected is, when I click the sub div, such as "sam",and

Disable contextmenu and rightclick menu

不打扰是莪最后的温柔 提交于 2020-01-06 03:52:04
问题 $(document).on('mousedown', 'a', function(event){ event.preventDefault(); if(event.which == 1){ if($(this).attr('target') != '_blank'){ loadpage($(this).attr('href')); } } }).on('contextmenu', 'a', function(event){ event.preventDefault(); }); Hello once again Stackoverflow! For my current project I want to disable the right and middle mouse button on every link. And when clicked on with the left mouse button, if the link doesn't contain target="_blank" , I need to call a function that loads

hover style can not apply when press mouse button in chrome

寵の児 提交于 2019-12-30 18:51:11
问题 All: [UPDATE] I find another way to implement this, not solution, but just a working trick: Use mousedown as a event trigger(because I need a drag action, so there should be a mousedown event anyway), inside that, bind mouseover event to that span(I do not know why, but bind mouseover inside mousedown can make mouseover work on span) , give it a new class which change the background color; The problem I had with Chrome 40 is: I set a style: span { background-color:red; } span:hover {

Mousedown Timer using JavaScript/jQuery

孤街醉人 提交于 2019-12-28 06:54:12
问题 How can I know how long a user has been holding the mouse button down (anywhere on a webpage)? I want to execute a function when the user held the mouse button for at least 2-3 seconds (preferably cancelling the mouse down in the process). Is this possible? 回答1: Here you go: $(window).mousedown(function(e) { clearTimeout(this.downTimer); this.downTimer = setTimeout(function() { // do your thing }, 2000); }).mouseup(function(e) { clearTimeout(this.downTimer); }); Live demo: http://jsfiddle.net