mouseevent

Swing persistent popup

血红的双手。 提交于 2019-12-05 21:37:56
I need to display a swing popup with my custom component. The popup should stay visible, until I hide it myself, but shouldn't get focus. I have a code written by some other developer that does it in the following way: popupMenu = new JPopupMenu(); popupMenu.add(myCustomComponent, BorderLayout.CENTER); popupMenu.setFocusable(false); popupMenu.setVisible(true); popupMenu.show(parentComponent, x, y); This seems to work, but has a bug - when the popup is visible, first mouse click outside the component is consumed by the popup. So I need to click twice to set focus to another component. How can I

On CTRL+MOUSEWHEEL event

我与影子孤独终老i 提交于 2019-12-05 20:25:51
I was asked to implement ctrl+mousewheel event for our page site in order to change image offset on user zoom in or zoom out. I found this old answer Override browsers CTRL+(WHEEL)SCROLL with javascript and I`ve tried to do the same. I downloaded the jQuery Mouse Wheel Plugin for the implementation and here is my code: var isCtrl = false; $(document).on('keydown keyup', function(e) { if (e.which === 17) { isCtrl = e.type === 'keydown' ? true : false; } }).on('mousewheel', function(e, delta) { // `delta` will be the distance that the page would have scrolled; // might be useful for increasing

Getting mouse click location of a label in qt

谁说我不能喝 提交于 2019-12-05 20:03:10
问题 I googled around and found this forum thread in which the OP seems to have had the exact problem I am having. The question is, how would I inherit from QLabel and reimplement the mousepressed event? I'm guessing it would be something like this: class CustomLabel : public QLabel { public: //what about the constructors? void mousePressEvent ( QMouseEvent * ev ); } void CustomLabel::mousePressEvent ( QMouseEvent * ev ) { QPoint = ev->pos(); //I want to have another function get the event

Label not showing on mouse event JavaFx

寵の児 提交于 2019-12-05 18:53:25
I have a pie chart where i have added a mouse listener using this guide: Oracle guide to pie chart However when i run my program and click on the chart it doesnt do anything. I have tried to System.out.println(caption.getText()); and the text of the label is correct however the label is just not showing up. My code is as following: public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Imported Fruits"); stage.setWidth(500); stage.setHeight(500); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Grapefruit", 13),

Pyautogui don't work in game window

不想你离开。 提交于 2019-12-05 17:52:30
I'm making some tests using Pyautogui on games. But in those games that change your cursor and fullscreen games, none of the methods work. I'm trying now on Ragnarok Online. I tried: pyautogui.click() pyautogui.moveTo(x, y, time) pyautogui.moveRel(x, y) None of them works when inside the game window. They work fine outside. Is there a way to make it work? Or another library that I could use? By the way, win32api.SetCursorPos((x,y)) also doesn't work. Thanks. obgnaw The source code of Pyautogui def _sendMouseEvent(ev, x, y, dwData=0): assert x != None and y != None, 'x and y cannot be set to

Elm: adding click events to SVG elements doesn't work – is this possible?

北慕城南 提交于 2019-12-05 17:27:54
I have been attempting to add an on "click" event to an SVG element in Elm in order to determine the relative position of the mouse click within that element. A code sample is given below that you can try running at http://elm-lang.org/try to show how click events on HTML elements seem to work as expected but not on SVG elements. In the sample, Html.on "click" is used rather than Html.onClick to allow the position data to be decoded from the event as explained in this discussion . After reading the documentation and the source code, I would expect that when the on "click" event is added to an

Detecting mouse event in an image with matplotlib

自古美人都是妖i 提交于 2019-12-05 16:37:32
So I'm trying write a program that detects a mouse click on an image and saves the x,y position. I've been using matplotlib and I have it working with a basic plot, but when I try to use the same code with an image, I get the following error: cid = implot.canvas.mpl_connect('button_press_event', onclick) 'AxesImage' object has no attribute 'canvas' This is my code: import matplotlib.pyplot as plt im = plt.imread('image.PNG') implot = plt.imshow(im) def onclick(event): if event.xdata != None and event.ydata != None: print(event.xdata, event.ydata) cid = implot.canvas.mpl_connect('button_press

-mouseMoved OSX does not get called in a sprite kit SKScene

余生长醉 提交于 2019-12-05 16:21:50
The following responder (defined in NSResponder) does not get called in an SKScene in OSX: -(void) mouseMoved:(NSEvent *)theEvent { DLog(@"TEST"); } I have said the window to accept mouse moved events in the app delegate. _window.acceptsMouseMovedEvents = YES; Thank you in advance. SOLUTION: Add to the app delegate: _window.acceptsMouseMovedEvents = YES; [_window makeFirstResponder:self.skView.scene]; Add to the app delegate: _window.acceptsMouseMovedEvents = YES; [_window makeFirstResponder:self.skView.scene]; In swift window.acceptsMouseMovedEvents = true; window.makeFirstResponder(self

Send a flag from server to clients using c# mouse events

戏子无情 提交于 2019-12-05 13:11:42
I am using sockets in c# in order to send data from server to client machine. In fact I have created a capturer which capature kinect stream from 3 different machine. I want to generate a server and client communication in order to send signal from server to the rest devices in order to begin and stop the recording process. I want with left click to send a message to begin recording and with right click to stop recording. My code is the following: public Form1() { InitializeComponent(); this.MouseClick += mouseClick1; Thread thread = new Thread(() => StartServer(message)); thread.Start(); //

Python time counter in Pygame-mouse events

匆匆过客 提交于 2019-12-05 11:45:26
I want to calculate the time of user's mouse events in Pygame, if user doesn't move his mouse about 15 seconds, then I want to display a text to the screen. I tried time module for that, but it's not working. import pygame,time pygame.init() #codes ... ... font = pygame.font.SysFont(None,25) text = font.render("Move your mouse!", True, red) FPS = 30 while True: #codes ... ... start = time.time() cur = pygame.mouse.get_pos() #catching mouse event end = time.time() diff = end-start if 15 < diff: gameDisplay.blit(text,(10,500)) pygame.display.update() clock.tick(FPS) pygame.quit() quit() Well