mouseevent

Pygame action when mouse 'click' on .rect?

风格不统一 提交于 2019-11-30 18:34:14
问题 I have been writing a test function to learn how a mouse 'click' action on a pygame.rect will result in a reponse. So far: def test(): pygame.init() screen = pygame.display.set_mode((770,430)) pygame.mouse.set_visible(1) background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((250,250,250)) screen.blit(background, (0,0)) pygame.display.flip() ## set-up screen in these lines above ## button = pygame.image.load('Pictures/cards/stand.png').convert_alpha()

How to detect the user is using the Trackpad and not the mouse in Java swing?

最后都变了- 提交于 2019-11-30 17:26:55
I hava a Java swing application that use a 'pan-able' JComponent to display large data. When the user move the mouse wheel, I listen to these events, and update the content of the JComponent from the scrolled amount. I would like to have a different behavior depending on whether the user is using a classical mouse using a touchpad, as the ones that can be found on modern Mac laptops. How could I detect that the user is using the mouse wheel vs the trackpad to generate the scroll event? I am relying in java 1.6 swing, si I cannot go to javaFX. Story behind the question: I just wanted to add a

Tracking mouse coordinates in Qt

空扰寡人 提交于 2019-11-30 17:20:17
问题 Let's say I have a widget in main window, and want to track mouse position ONLY on the widget: it means that left-low corner of widget must be local (0, 0). Q: How can I do this? p.s. NON of functions below do that. widget->mapFromGlobal(QCursor::pos()).x(); QCursor::pos()).x(); event->x(); 回答1: I am afraid, you won't be happy with your requirement 'lower left must be (0,0). In Qt coordinate systems (0,0) is upper left. If you can accept that. The following code... setMouseTracking(true); //

WPF: Slider doesnt raise MouseLeftButtonDown or MouseLeftButtonUp

痴心易碎 提交于 2019-11-30 17:17:51
I tried this XAML: <Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" /> And this C#: private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { sliderMouseDown = true; } private void slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { sliderMouseDown = false; } The sliderMouseDown variable never changes because the MouseLeftButtonDown and MouseLeftButtonUp events are never raised. How can I get this code to work when a user has the left mouse button down on a

How to simulate mouse click from Mac App to other Application

人走茶凉 提交于 2019-11-30 17:08:50
I am trying to simulate mouse click on iphone simulator from macos App for that I am using CGEvents . the process id is 33554 for iPhone simulator let point = CGPoint(x: 500 , y:300) let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left) let eventMouseUp = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left) eventMouseDown?.postToPid(33554) eventMouseUp?.postToPid(33554) I have also noticed that It simulates mouse click when ios simulator window is focused and only works

WPF: Slider doesnt raise MouseLeftButtonDown or MouseLeftButtonUp

拈花ヽ惹草 提交于 2019-11-30 16:37:19
问题 I tried this XAML: <Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" /> And this C#: private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { sliderMouseDown = true; } private void slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { sliderMouseDown = false; } The sliderMouseDown variable never changes because the MouseLeftButtonDown and MouseLeftButtonUp

Perform a mouse Click event on another Application using C#

99封情书 提交于 2019-11-30 16:35:48
what i need to do is that I need to control another application installed on the same machine using my custom application. For example if i needed to use the standard windows calculator I would simply send the input events to the calculator. I have used some code snippets to make this possible and I have now triggered both mouse and keyboard events. but the problem is that i can be sure that the keyboard event will hit the target application because it has the process handle. but i cannot be sure about the mouse. and also if the target application goes into background, i cannot initiate mouse

Simulate mouse on Mac

扶醉桌前 提交于 2019-11-30 15:58:21
I have a virtual trackpad on my iPhone and to move my mouse I'm using : CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, CGPointMake(((float)aD.msg)+location.x, ((float)aD.msg2)+location.y)); It's working well but this not a real mouse because when I put my mouse on my hidden dock, this one doesn't display it self. I don't understand why. More over I tried to simulate mouse click with : case MOUSECLICK: [self postMouseEventWithButton:0 withType:kCGEventLeftMouseDown andPoint:CGEventGetLocation(CGEventCreate(NULL))]; [self postMouseEventWithButton:0 withType:kCGEventLeftMouseUp andPoint

In React, onMouseEnter or hover is not working as expected

帅比萌擦擦* 提交于 2019-11-30 15:23:59
I have one image with opacity = 1 at the beginning. When mouse enters the image, change opacity = 0.5 . When mouse leaves the image, change the opacity back. here is one code: mouseEnter() { console.log('mouse enter') const classname = '.' + this.props.post.code document.querySelector(classname).classList.add('image-hover-opacity') } mouseLeave() { console.log('mouse leave') const classname = '.' + this.props.post.code document.querySelector(classname).classList.remove('image-hover-opacity') } render() { <img src={src} onMouseEnter={::this.mouseEnter} onMouseLeave={::this.mouseLeave} /> }

How to draw a rectangle on a java applet using mouse drag event and make it stay

断了今生、忘了曾经 提交于 2019-11-30 14:23:26
问题 I have my program that can draw rectangles. I have two problems I can't solve. After I draw the rectangle it won't stay. The only code I have that clears the canvas in under paint, repaint is only called on mouse drag. Why when I mouse release or mouse move does my canvas clear. The second thing isn't as much a problem, but something I can't figure out, when either the height or width of my rectangle is negative the rectangle is filled in black. package pracpapp2; import java.awt.*; import