mouse

Java Read Raw Mouse Input

a 夏天 提交于 2019-12-20 04:34:11
问题 I'm looking for a way in Java to read in raw mouse input and not just the event listeners. I'll tell you what I'm doing. Essentially, there is a game where if you move the mouse to the right, I want Java to send key signals of the 'd' key being pushed down, and when the mouse is moved to the left, the 'a' key being held down. But, when you move the mouse, the game quickly corrects the mouse position and sends it right back into the middle of the screen. So, if you use mouse listener, you get

Move the player in the position of the mouse in pygame

六月ゝ 毕业季﹏ 提交于 2019-12-20 04:23:08
问题 I have a fixed player in center of the screen and for now I'm moving the background and the elements in the opposite direction to give the illusion of moving forward with the directional keys. But now, I want to detect the position of the mouse and deplace the player in the direction of the mouse (as in the game agar.io for example) and that the acceleration depends on the distance with the object (the further the mouse is, the faster the player moves forward and if the mouse is on the player

WinForms cursor hidden only on one Form

杀马特。学长 韩版系。学妹 提交于 2019-12-20 03:29:18
问题 I have a C# application with 2 simultaneous visible forms, and I need to hide mouse cursor when it is over only on one of them. If I use Cursor.Hide() it applies the change for both of them. 回答1: You can make a "blank" cursor, and set myForm.Cursor = blankCursor; This will make that specific form show a specific cursor, which could be completely transparent. 回答2: You need to implement this logic by using the MouseEnter and MouseLeave events one each form something like: private void frm1

Scrolling in NSScrollView stops when overwriting scrollWheel function

天涯浪子 提交于 2019-12-20 03:12:30
问题 I experience a weird bug when I overwrite the scrollWheel(theEvent: NSEvent) function in a NSScrollView. Here's my code: import Cocoa class GraphScrollView: NSScrollView { var axisScrollViewInstance: AxisScrollView? override func scrollWheel(theEvent: NSEvent) { if theEvent.deltaY != 0 { axisScrollViewInstance?.scrollEventFromOtherScrollView(theEvent) super.scrollWheel(theEvent) } else if theEvent.deltaX != 0 { super.scrollWheel(theEvent) } } } class AxisScrollView: NSScrollView { var

Finding Monitor/Screen on which mouse pointer is present

不问归期 提交于 2019-12-20 02:41:40
问题 I will start from beginning, I aw working on an application which will span over multiple monitors, each monitor will contain a single WPF window and these windows are controled using a single viewmodel class. now lets say i have a button on all the windows at 200,300 (x,y) and i want that this button should be responsible for a tool on same window, while all rest are responsible for the application. When i try to get current mouse position or last click position i get position relative to

pygame how to check mouse coordinates

亡梦爱人 提交于 2019-12-20 01:46:44
问题 I am making a multiple choice quiz game with python and pygame. I have circles and what a want is when you click on the circle it will change the width and make the circle full. But I don't know of a python function that can do that Heres my code so far: # Controls the width of the circles width_1 = 2 width_2 = 2 width_3 = 2 width_4 = 2 # Circles pygame.draw.circle(screen, BLACK, [250, 230], 7, width_1) pygame.draw.circle(screen, BLACK, [250, 260], 7, width_2) pygame.draw.circle(screen, BLACK

pygame how to check mouse coordinates

旧时模样 提交于 2019-12-20 01:46:30
问题 I am making a multiple choice quiz game with python and pygame. I have circles and what a want is when you click on the circle it will change the width and make the circle full. But I don't know of a python function that can do that Heres my code so far: # Controls the width of the circles width_1 = 2 width_2 = 2 width_3 = 2 width_4 = 2 # Circles pygame.draw.circle(screen, BLACK, [250, 230], 7, width_1) pygame.draw.circle(screen, BLACK, [250, 260], 7, width_2) pygame.draw.circle(screen, BLACK

Mouse Down events in Objective-C

风格不统一 提交于 2019-12-20 01:46:22
问题 I know this question has been asked a lot before, but nothing will work for me. The following code will not do anything at all. - (void) mouseDown:(NSEvent*)event { NSLog(@"It worked!"); } I have tried a lot of different methods to get this to work, including creating custom NSEvents in this way: NSEvent *someEvent; - (void) mouseDown:(NSEvent*)someEvent { NSLog(@"It worked!"); } This is my .h file: @interface test : NSWindow <NSWindowDelegate> { } Would somebody explain how to make this do

How to get cardinal mouse direction from mouse coordinates

家住魔仙堡 提交于 2019-12-19 18:23:30
问题 is it possible to get the mouse direction (Left, Right, Up, Down) based on mouse last position and current position? I have written the code to calculate the angle between two vectors but I am not sure if it is right. Can someone please point me to the right direction? public enum Direction { Left = 0, Right = 1, Down = 2, Up = 3 } private int lastX; private int lastY; private Direction direction; private void Form1_MouseDown(object sender, MouseEventArgs e) { lastX = e.X; lastY = e.Y; }

Hide cursor in fullscreen mode using Qt 4.8?

心已入冬 提交于 2019-12-19 17:30:19
问题 I'm in a ArchLinux with OpenBox and I want to hide the cursor on fullscreen inside a Qt 4.8 application. I am aware about some other question about it but no one works every time: sometimes the cursor is hiding, sometimes not. I didn't managed to understand exactly when the problem occurs but I think that maybe is it related with the screensaver because if I test my application just after the computer is restarted the mouse cursor is no visible (and it is what I want) but if I test this