mouseevent

Send mouse & keyboard events

删除回忆录丶 提交于 2019-11-28 09:21:40
I'm developing an app that have to send some keys or mouse events to the active window. I'm using this class: Mouse using System.Runtime.InteropServices; using System.Windows.Forms; namespace Mouse { public static class VirtualMouse { // import the necessary API function so .NET can // marshall parameters appropriately [DllImport("user32.dll")] static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); // constants for the mouse_input() API function private const int MOUSEEVENTF_MOVE = 0x0001; private const int MOUSEEVENTF_LEFTDOWN = 0x0002; private const int

Draw a line with two mouse clicks on HTML5 canvas?

独自空忆成欢 提交于 2019-11-28 09:19:32
How do I draw a line with two mouse clicks on canvas? The code is quite simple, but you have to get a good foundation: Demo : http://jsfiddle.net/NpDdt/10/ JavaScript : var clicks = 0; var lastClick = [0, 0]; document.getElementById('canvas').addEventListener('click', drawLine, false); function getCursorPosition(e) { var x; var y; if (e.pageX != undefined && e.pageY != undefined) { x = e.pageX; y = e.pageY; } else { x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } return [x, y]; }

How to insert synthetic mouse events into X11 input queue

非 Y 不嫁゛ 提交于 2019-11-28 09:14:56
I've got an embedded device running Linux/X11 that is connected to a device that provides touch events over a USB connection. This device is not recognized as any form of standard pointer/mouse input. What I'm trying to do is find a way to "inject" mouse events into X11 when the external device reports an event. Doing so would remove the need for my application ( written in C using Gtk+ ) to fake mouse presses with Gtk+ calls. If this can be done my Gtk+ application would not need to know or care about the device generating the touch events. It would just appear to the application as standard

Which mouse button is the middle one?

和自甴很熟 提交于 2019-11-28 08:59:30
I'm currently developing a program in Java where a certain event must be triggered only when the user clicks with both the left and the right click on a button. Since it is a little unconventional, I decided to first test this. Here it is: import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; public class GUI { private JFrame mainframe; private JButton thebutton; private boolean left_is_pressed; private boolean right_is_pressed; private JLabel notifier; public GUI () { thebutton = new JButton (

MouseListener on JFrame

我们两清 提交于 2019-11-28 08:06:45
问题 I want to be notified of mouse events (specifically the mouse entered and exited events) on my JFrame. But when i add a mouselistener to it i get the events on the borders of the frame not the entire frame with it's contents. Any ideas as to why? EDIT : Or at least do you have an alternative? I want a "gloabal" way to catch mouse events on the JFrame. Maybe a mouselistener is not the answer. 回答1: You can get all events and check if their source is a component in the JFrame. See Toolkit

swing mouse listeners being intercepted by child components

▼魔方 西西 提交于 2019-11-28 08:05:38
问题 I have a swing component that has several sub components. What I want to do change some label if the mouse is over any of those components, and then change it to something else if the mouse moves off all of the components. I'm trying to find a more efficient way to do this. Currently I have mouse listeners over all of the child components that look something like: class AMouseListener extends MouseAdapter { private boolean mouseOver; mouseEntered(MouseEvent e) { mouseOver = true; updateLabel(

Getting MouseMoveEvents in Qt

…衆ロ難τιáo~ 提交于 2019-11-28 08:04:15
In my program, I'd like to have mouseMoveEvent(QMouseEvent* event) called whenever the mouse moves (even when it's over another window). Right now, in my mainwindow.cpp file, I have: void MainWindow::mouseMoveEvent(QMouseEvent* event) { qDebug() << QString::number(event->pos().x()); qDebug() << QString::number(event->pos().y()); } But this seems to only be called when I click and drag the mouse while over the window of the program itself. I've tried calling setMouseTracking(true); in MainWindow's constructor, but this doesn't seem to do anything differently (mouseMoveEvent still is only called

Find the velocity of the mouse in C#

Deadly 提交于 2019-11-28 07:49:50
问题 How can i find the instantaneous vertical speed of the mouse at the exact moment that the mouse is released? i have the users dragging over a custom control and when they release i need to know this information so i can continue the object they were dragging using the vertical component of the velocity... so for instance, if they were dragging at an angle, use trig to determine the vertical speed and then use that.. i cant just do distance over time, because the mouse can be moved at

How do I add a .click() event to an image?

核能气质少年 提交于 2019-11-28 07:36:57
I have a script that places an image based on a mouse click thanks to Jose Faeti . Now I need help adding a .click() event to the code below so that when a user clicks the image it performs the function shown in the script. <img src="http://soulsnatcher.bplaced.net/LDRYh.jpg" alt="unfinished bingo card" />.click() I put the entire code below, in case you want to see it. <html> <head> <script language="javascript" type="text/javascript"> <!-- document.getElementById('foo').addEventListener('click', function (e) { var img = document.createElement('img'); img.setAttribute('src', 'http://blog

How can a control handle a Mouse click outside of that control?

假装没事ソ 提交于 2019-11-28 07:22:36
I'm writing a custom control and I'd like the control to switch from an editing state to it's normal state when a user clicks off of the control. I'm handling the LostFocus event and that helps when a user tabs away or if they click on to another control that's Focusable. But if they don't click on something Focusable, it won't switch out of it's editing state. So I have two solutions in mind: Walk up the tree to the top most element when it goes in to an editing state and add a handler for MouseDownEvent (and handle "handled" events). In the handler I'd kick the control out of it's editing