mouse

How do I get the coordinates of the mouse when a control is clicked?

纵饮孤独 提交于 2019-11-29 18:17:12
问题 In a TImage's OnClick event, I would like to extract the x,y coordinates of the mouse. I would prefer them in relation to the image, but in relation to the form or window is just as good. 回答1: Mouse.CursorPos contains the TPoint, which in turn contains the X and Y position. This value is in global coordinates, so you can translate to your form by using the ScreenToClient routine which will translate screen coordinates to window coordinates. According to the Delphi help file, Windows

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

Preventing opera mouse gestures

匆匆过客 提交于 2019-11-29 15:57:36
Is it possible to prevent opera mouse gestures for right button? I have web app on html5 and I decided to use right mouse button. But it doesnt work in opera, because opera has mouse gestures. event.preventDefault(); // it doesn't work May be anybody knows? Thank you. It doesn't actually have anything to do with gestures specifically. Opera doesn't allow scripts to detect context menu events by default so you'd have to ask users to change their site preferences for your site to allow scripts to detect context menu events. Right click -> Edit Site Preferences -> Scripting (tab) -> Allow scripts

Global Mouse Hook + Simulate Mouse Inputs

僤鯓⒐⒋嵵緔 提交于 2019-11-29 15:43:07
问题 I'm looking to create a global mouse hook that works in XP/Vista/7 which would allow me to access the X,Y values that the mouse is inputting, and modify those values before they hit Windows... I also want to be able to simulate mouse inputs in between actual mouse inputs... For example, lets say our inputs looked like this: 1: 1,0 2: 2,0 3: 3,0 4: ?,? I want to be able to intercept input number 4 and run it through an 'if' statement: If the value of the input matches certain parameters, I

[WIN]让Panel对Mouse滚轮事件(Wheel)有感觉

依然范特西╮ 提交于 2019-11-29 12:41:38
让Panel对Mouse滚轮事件(Wheel)有感觉 最近有看到朋友谈到“panel 选轴捆动与 textbox 疑问”。 如果TextBox在Panel中的话,Focus在TextBox上,滑动Mouse滚轮的话,如果Panel有Scroll的话,是会跟着滑动的! 但是如果Focus所在的TextBox不在Panel之中,那Mouse在有Scroll的Panel上滑动Mouse滚轮,panel是不会理你的哦! 因为Panel默认是不会吃Focus的哦! 而且目前Focus是在Panel外面的TextBox上,不可以切换Focus过来! 那要如何做呢? 在网络上有找到解法“Mouse Wheel Event (C#)”,马上记录下来。 在Winform上放了一个Panel里面放了一堆Button,并设定AutoScroll=True,再放一个TextBox在Panel外面,如下的画面, 而程序中作法如下, 1.您的form要实践 IMessageFilter 2.加入PreFilterMessage method 3.在Form的建构函数中加入Application.AddMessageFilter(this); Code如下, using System; using System.Drawing; using System.Runtime.InteropServices;

any way to detect ctrl + click in javascript for osx browsers? no jQuery

蹲街弑〆低调 提交于 2019-11-29 12:34:06
using vanilla js. Any way to grab the "right-click" (option-click) from OSX? function clickey(e) { if(event.button==2 || /*how you'd do it in Java=)*/ e.getButton() == MouseButton.BUTTON3 ) ... } but in js, how do eeet? You need to listen to the contextmenu event. This is triggered when the context menu should be shown. So either if the right mouse butten or or ctrl + mouse . If it is not supported then you can try to check the mousedown event where button is 2 and ctrlKey is true if it is triggered by using ctrl + mouse document.addEventListener("contextmenu",function(event){ }); OR

Scrollbars in dropdownlist inside DataGrid itemEditor not working

本小妞迷上赌 提交于 2019-11-29 11:33:16
I have a DropDownList inside the itemEditor of my DataGrid. There are enough items in the DropDownList to justify scrollbars. You can see the scrollbars, and the mousewheel works fine. If you move the mouse over the scrollbars, they'll change appearance fine (mouseover is working). If you click on them, the DropDownList closes as if you'd clicked elsewhere in the data grid. There's a comment on the Adobe Forums that describe the same problem, but it is fairly old and has not been answered. I've been experimenting with custom skins hoping to find a way to trap the mouse event, but have been

How do I set the position of the mouse in Java?

偶尔善良 提交于 2019-11-29 11:19:44
问题 I'm doing some Swing GUI work with Java, and I think my question is fairly straightforward; How does one set the position of the mouse? 回答1: You need to use Robot This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations. Using the class to generate input events

User control click event not working when clicking on text inside control?

只谈情不闲聊 提交于 2019-11-29 10:38:45
I have a user control called GameButton that has a label inside it. When I add the user control to my form, and add a click event to it, its triggered when you click on the background of the custom button, but not the text in the label? How would I fix this without adding a bunch of click events inside the user controls code? edit: UI framework: winforms ImGreg If I am understanding you properly, your GameButton usercontrol will fire the event when clicked on, but not when the label is clicked on -- and you want both. This is because the label (a control) is on top of the background. Therefore

How to get mouse position over a certain control

微笑、不失礼 提交于 2019-11-29 10:35:44
Windows Form I'm using the DragOver event on a layoutpanel and the DragEventArgs returns the X/Y coordinates of the mouse in relation to the screen. I know there is a function to translate this in to the position of the mouse over the control, but I'm having difficulty locating it. Try Control.PointToClient and Control.PointToScreen . 来源: https://stackoverflow.com/questions/465545/how-to-get-mouse-position-over-a-certain-control