Questions tagged [nsevent]

An object sent along to your app from macOS that contains information about an input action such as a mouse click or a key press.

221 questions
7
votes
1 answer

Capture key press events while NSMenu is open

I'm interested in capturing key presses while a NSMenu is open. For example, if the menu is open and the user presses "e", or "1" on the keyboard, send a particular message (preferably passing an event object which contains reference to which key…
Dustin Senos
  • 243
  • 1
  • 9
7
votes
2 answers

How to capture Unicode from key events without an NSTextView

I'd like to capture key events from any window in the application and interpret them as Unicode. For example, if the user types Option-e-e (on a default-configured US English keyboard), I would like to recognize that as "é". I tried capturing…
jlstrecker
  • 4,953
  • 3
  • 46
  • 60
7
votes
2 answers

How to stop listening for NSEvents?

I have a problem with listening for events, I can listen for events which works perfectly however I can't make it stop listening to events. I researched it for a while and came up with the a method, + (void)removeMonitor:(id)eventMonitor, that it…
A.sharif
  • 1,977
  • 1
  • 16
  • 27
6
votes
3 answers

Receiving double-click event

I've been searching the Apple docs and the only function I could find pertaining to a double click just returned the acceptable time between clicks for it to be considered a double click. Can someone please show me an example of a double click…
Sciguy77
  • 349
  • 6
  • 14
6
votes
4 answers

Click-through buttons and not raising the window

The iTunes mini-player (to give just one example) supports click-through where the application isn't brought to the front when the play/pause and volume controls are used. How is this done? I've been looking through Apple's documentation and have a…
user103152
5
votes
2 answers

NSEvent: test for only one modfierkey

Ok, I understand how to determine from an NSEvent if a modifierkey is pressed : if ([theEvent modifierFlags] & NSAlternateKeyMask) { // The Option/Alt key was pressed } But this also captures the optionkey and another modifierkey at the…
koen
  • 5,383
  • 7
  • 50
  • 89
5
votes
4 answers

Wrong location using [NSEvent mouseLocation]

I make a iphone remote mouse controller application for Mac: the iPhone application sends the coordinate values to the Mac, which then processes mouse location value. To get the current mouse location on the Mac, the receiver calls [NSEvent…
이민규
  • 151
  • 2
  • 4
  • 8
5
votes
1 answer

Using arrow keys in cocoa?

I was doing a little research into this, and I found this question. I implemented the code used there, but nothing happened. Here is the exact code I am using: .h file #import @interface Test : NSView…
Justin
  • 2,122
  • 3
  • 27
  • 47
5
votes
2 answers

NSMenu Pressed Mouse Button in 10.5

I’m updating (downdating?) an application I’ve written for 10.6+ to work in 10.5+. I’m struggling with capturing the currently pressed mouse button in the -(void)menuWillOpen:(NSMenu *); selector. For 10.6+ I’m taking advantage of the [NSEvent…
Dustin Senos
  • 243
  • 1
  • 9
5
votes
2 answers

Cocoa application: scroll programmatically?

I'm currently developing a cross plattform application for iOS and macOS that makes your iOS device function as a track pad. Using CGDisplayMoveCursorToPoint, I can move the cursor on the screen. Works like a charm. With this piece of code in the…
Dennis
  • 992
  • 1
  • 10
  • 23
5
votes
2 answers

Detect left and right click events on NSStatusItem (Swift)

I’m building a status bar app and want to call different actions depending on if the user clicked left or right. Here’s what I have so far: var statusItem = NSStatusBar.system().statusItem(withLength: -1) statusItem.action =…
ixany
  • 5,433
  • 9
  • 41
  • 65
5
votes
2 answers

Register for global file drag events in Cocoa

I'm trying to be notified when a OS X user is dragging any file in OS X, not only in my app. My current approach was using addGlobalMonitorForEventsMatchingMask:handler: on NSEvent, as follows: [NSEvent…
Timo Josten
  • 656
  • 1
  • 5
  • 16
5
votes
1 answer

NSTextView: how to disable single clicks but still allow selection for copy-and-paste?

I have NSTextView-based component and I would like to disable single clicks on it, so that its insertion point is not affected by these single clicks, but still to be able to select pieces of text for copy-and-paste work: single clicks do…
Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
5
votes
1 answer

In OSX, how to determine which keyboard generated an NSEvent?

I've been trying to determine (from within the event handler) which keyboard triggered the event. I've been using these two posts: http://www.cocoabuilder.com/archive/cocoa/229902-which-keyboard-barcode-scanner-did-the-event-come-from.html…
P i
  • 29,020
  • 36
  • 159
  • 267
5
votes
2 answers

How to forward keyboard up/down events from NSTextField to a NSTableView?

I'm trying to simulate the way Spotlight works in Yosemite where the NSTextField (search field) always retains focus when hitting the up/down arrow keys and moves the tableview selection up and down. I've implemented the following code: -…
Camsoft
  • 11,718
  • 19
  • 83
  • 120
1
2
3
14 15