mouseevent

Mouse events blocked because of QGL View

岁酱吖の 提交于 2019-12-10 12:28:13
问题 I created a simple project to show the problem I have in a bigger application. So, I create a mainwindow with 2 buttons. I create a class which inherit from QWidget with 2 buttons and a QGL view. The problem is that, apparently and for some reason I don't find, the creation of this QGL view blocks some events of the views, particularly mouse events. In the code below, the mouse hover events on the buttons and the main widget of class 1 are not detected (the cursor has to change from Arrow to

JTextArea - enable edit only at the end of document

被刻印的时光 ゝ 提交于 2019-12-10 11:45:13
问题 I use a JTextArea where using double click I can able to select the word at any place but I don't want to enable edit. Which means text can be entered only at the end of text area and not anywhere in between. I have tried with mouse listeners like below: @Override public void mouseClicked(MouseEvent me) { if(SwingUtilities.isLeftMouseButton(me)){ System.err.println("clicked"); int pos = textArea.getCaretPosition(); if(pos < textArea.getDocument().getLength()){ textArea.setCaretPosition

Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

只愿长相守 提交于 2019-12-10 10:42:07
问题 I have a Status-Bar item only app that Iam trying to get to show a panel on mouseOver. I have the custom status item (and associated view) hooked up and working, but the tracking rect is only receiving events on every dozen or so launches. This leads me to believe there is a race condition happening somewhere, but I can't find it. In my custom status bar item view: - (id)initWithStatusItem:(NSStatusItem *)statusItem { CGFloat itemWidth = [statusItem length]; CGFloat itemHeight = [[NSStatusBar

JFreeChart interactive chart editing handling ChartMouseEvent

感情迁移 提交于 2019-12-10 10:36:18
问题 I'm trying to intercept ChartMouseEvent in order to modify an XYSeries of a JFreeChart object created with ChartFactory.createXYLineChart method (and displayed using a JDialog). I retrieve successfully the coordinate of the mouse event this way: public void chartMouseMoved(ChartMouseEvent arg0) { int x = arg0.getTrigger().getX(); int y = arg0.getTrigger().getY(); The origin of the coordinate system (0,0) is located at the red square in the picture. Now, I would like to calculate in which

Disappearing Problems Using a Released MouseEvent In Java

房东的猫 提交于 2019-12-10 10:30:55
问题 Currently I have a game that I am building in Netbeans, and have been able to create a board, place the pieces and allow them to be moved anywhere using mouseveent's But now I have ran into a problem when trying to code the pieces on the board to only do allowed actions. The problem I am having is that every piece is still allowed to be moved but now when it is moved the selected piece disappears from the board completely ingorning all the new function in the mouse release event The code I am

Getting mouse cursor position and button state on Windows

与世无争的帅哥 提交于 2019-12-10 10:30:05
问题 What is the most appropriate way of getting the mouse cursor position or button state on Windows (Windows 7 and above)? I previously used DirectInput, but I am not longer using it and do not wish to. I saw there is GetCursorPos, however, I do not see anything for getting mouse button states. I have read previously that just reading the window messages (such as WM_LBUTTONUP) was considered "slow" for real time applications, so I do not know of any other option. 回答1: If you want to poll/query

Is it possible to detect if Magic Mouse/Trackpad is being touched?

心不动则不痛 提交于 2019-12-10 10:25:16
问题 Just wondering if there is a way to receive a callback in Cocoa if Magic Mouse or Trackpad is being touched by the user? I looked into Quartz Events, but it seems I can only get callbacks if the mouse is moving or clicked etc. Note that I want to receive a callback even if my app is not active. It's a background utility app. Also, it can't use private frameworks as it's going to be a Mac App Store app. 回答1: You could use this code to trap the events: (create a new Cocoa application and put

How to have mouseEntered execute only if mouse is pressed down in Java

和自甴很熟 提交于 2019-12-10 10:15:58
问题 I Want to execute the mouseEntered only IF the mouse is currently pressed down, basically this: @Override public void mouseEntered(MouseEvent e) { if(e.mouseDown()){ //Do stuff } } can I do it like this, or do I need a mouse motion listener or what? Thanks! EDIT: Sorry should have made this more clear, but I need the mouse to be press down Before it enters the component, its like holding down the mouse and hovering over the component activates the listener 回答1: You might want to evaluate the

Swing persistent popup

随声附和 提交于 2019-12-10 10:14:32
问题 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

Detect right mouse click on cocoa

爱⌒轻易说出口 提交于 2019-12-10 07:04:47
问题 I'm trying to manage mouse events in my prototype of Sprite-kit game. I used the following methods from the question SO_q - (void) mouseDown: (NSEvent*) theEvent { NSLog(@"Click!"); } - (void) rightMouseDown:(NSEvent*) theEvent { NSLog(@"DERECHA PULSADA!"); } But the method to detect the right clic doesn't work for me. I want to detect click and drop of right mouse click. How can i detect when the mouse click is dropped ? UPDATE: I tried with the following mehod, picked up from the Cocoa