Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
61 views

In my macOS app (objC), the user can trigger tasks that can take some time, like importing files into a database. These tasks do not run on the main thread because they spawn a window (sheet) to show ...
jeanlain's user avatar
  • 475
1 vote
0 answers
86 views

I try to use Java's FFM API to call NSEvent.addGlobalMonitorForEventsMatchingMask on macOS. import java.lang.foreign.*; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; ...
Ysxz Y's user avatar
  • 11
0 votes
1 answer
60 views

I have implemented type selection for my NSCollectionView implementation. In my collection view subclass, I have added additional delegate methods: protocol CollectionViewDelegate : ...
Silver's user avatar
  • 11
0 votes
0 answers
244 views

I'm developing a Mac application for the menu bar to manage a list of values copied via command + c. I would like my app to perform actions when I press that key combination, even when it is not ...
Cristiano Aloigi's user avatar
-1 votes
1 answer
96 views

Is there anyway to read keyboard inputs in AppKit off the main thread? I've managed to do so using CGEventTapCreate but unfortunately it requires permissions I'd rather not have to request. Is there a ...
loats's user avatar
  • 1
1 vote
1 answer
91 views

So I am trying to add WASD movement to my playCharacter class in Cocoa Swift (not using Xcode): import Cocoa public class playerCharacter: NSView { var x: Int var y: Int let color: ...
Salty4141's user avatar
1 vote
0 answers
177 views

We're developing a Unity editor extension. For that we need to know the double click interval of the OS. On windows you can get this with an external call like so (how to get the double-click-time in ...
Meister der Magie's user avatar
1 vote
0 answers
357 views

I am trying to post a command + mouse drag event to a specific window. Create an NSEvent Post the underline cgevent It does not work whether with postToPid or post. What I want to achieve is that: ...
chunyang.wen's user avatar
0 votes
0 answers
218 views

This is the code I tried.It gives the mouse Click event in macOS let eventObserver = NSEvent.addGlobalMonitorForEvents(matching: NSEvent.EventTypeMask.leftMouseDown) { (event) -> Void in Swift....
Ravindu Tharanga Perera's user avatar
0 votes
2 answers
322 views

I'm trying to programmaticaly send a custom key event (function keys, media keys) but it only works in interpreted mode, not in compiled code. I tried using the following answer: emulate media key ...
Stephan Burlot's user avatar
0 votes
1 answer
68 views

My son noted that he could not use the cursor keys to move in a simple game I wrote. I followed the guide found here on SO, and now you can move the four cardinal directions. But the game allows eight ...
Maury Markowitz's user avatar
0 votes
2 answers
1k views

I want to detect ONE mouse down and ONE mouse up event on my view (a simple Rectangle). Here is the code I already made. Unfortunately I got a lot of 'mouse down' and 'mouse up' on the console. This ...
Sébastien REMY's user avatar
0 votes
0 answers
231 views

I made a command line tool years ago that worked fine up until macOS Monterey. The code below no longer works for a command line tool. It works fine if I use a macOS application. I need a command line ...
Bobby's user avatar
  • 6,265
1 vote
1 answer
388 views

I'm trying to intercept mouse click events inside SpriteKit SKScene inside a a SwiftUI SpriteView in Mac OS. Overriding touchesBegun() that accepts an NSEvent object is never called when I click ...
andrewz's user avatar
  • 5,300
0 votes
0 answers
91 views

I have a command line application and I would like to receive global mousemove and keypress events as well as some notifications. However this will not work. The console Application does have ...
Silve2611's user avatar
  • 2,278
0 votes
0 answers
233 views

I'm working on a mac app that has similar functionalities to the rocket app. Whenever the user types : outside of my app I'll show an NSPopover with NSTableView near the cursor. The problem I'm facing ...
Arul Murugan Sivapoosam's user avatar
-1 votes
1 answer
635 views

I would like to be able to get either the key code or the characters/text from an NSEvent/KeyEvent. Absolutely no idea how to do this as the documentation I have found so far has been very limited. My ...
Liam Kinghouser's user avatar
0 votes
0 answers
138 views

Some built in AppKit components temporarily "pause" NSTrackingArea updates while their content is being scrolled or resized. For example, if you inspect tracking areas using the Quartz Debug ...
Adam S's user avatar
  • 271
4 votes
1 answer
295 views

I'm trying to prevent the mouse cursor from leaving a specific area of the screen. I can't find a native method to do this, so I'm trying to do it manually. So far I have this: NSEvent....
mxrlkn's user avatar
  • 93
1 vote
1 answer
1k views

The error occurs when I was using jupyter notebook I am using a m1 macbook pro with monterey 12.1, lastest version as this is being written Here is my code import matplotlib.pyplot as plt %matplotlib ...
lee's user avatar
  • 11
3 votes
2 answers
583 views

I've started a SwiftUI project (it is a macOS tray application) that relies on global keyboard events (even when my application is minimized). Specifically i care about the F3 and F4 keys. While the ...
tstamatakis's user avatar
1 vote
0 answers
92 views

I am having trouble getting cursor updates with addGlobalMonitorForEventsMatchingMask and NSEventMaskCursorUpdate. I was hoping this handler would be called when the (global) mouse cursor changes, but ...
Jochen's user avatar
  • 1,853
0 votes
0 answers
497 views

override func mouseDown(with event: NSEvent) { let startPoint = event.locationInWindow print(startPoint) //for top left it prints (0, 900) To my knowledge the screen's origin is ...
unknown's user avatar
  • 1,038
2 votes
2 answers
2k views

I am using event monitor to detect the key press event in swift. However, event monitor doesn't seem to detect command key or any other modifier key (shift, tab, opt ...) press. Is there a different ...
unknown's user avatar
  • 1,038
0 votes
1 answer
494 views

I am trying to do something when a given key is pressed in a macOS App. First, I ran into a problem where the keyDown event was detected multiple times on each press, therefore executing the handler ...
unknown's user avatar
  • 1,038
3 votes
1 answer
572 views

NSEvent keydown code is running repeatedly when key is pressed. How do I make sure that the event runs only once then stop listening until key up event occurs? override func viewDidLoad() { ...
unknown's user avatar
  • 1,038
2 votes
1 answer
991 views

I am trying to get NSEvent to stop listening to local event. Is there a way to access the event after creating it?(which is what I unsuccessfully tried in removeEvent) override func viewDidLoad() {...
unknown's user avatar
  • 1,038
1 vote
1 answer
247 views

I have a custom button that subclasses NSButton. I want to change the content tint color when the button is in pressed state. This is what I have: open override func mouseDown(with event: NSEvent) { ...
manchiu's user avatar
  • 13
0 votes
2 answers
564 views

I'm a windows developer and I'm having a hard time understanding the right way to run code in the NSApplication's main thread. Most of my code is running in a cvdisplaylink thread (it's an opengl ...
Stas L's user avatar
  • 5
0 votes
1 answer
56 views

So I am working on a sort of GLFW-lite framework and am doing the cocoa part. I am trying to get the input working but it is not working. Basically, my view interface has a pointer to a struct with an ...
James51332's user avatar
1 vote
1 answer
2k views

I have tried KeyDown and NSEvent, but they require a NSWindow object to be active. My hope is that I can put an app on the status bar and alert the user when it has pressed CapsLock, even if the user ...
Ryu's user avatar
  • 379
0 votes
0 answers
31 views

I want to capture events from an apple remote in a macOS App. I tried to use EventTap to capture CGEvent from the system and found it do send an event. Then I turn it into NSEvent, then found the ...
Megabits's user avatar
  • 666
0 votes
0 answers
579 views

Apple provides https://developer.apple.com/documentation/appkit/nseventtype/nseventtypesystemdefined?language=objc This page says nothing more than: No overview available. Declaration: ...
P i's user avatar
  • 31.3k
1 vote
1 answer
392 views

So I have a NSTableView inside NSWindowController. When I press spacebar it goes through NSResponder and stops on NSWindow which calls performClick: on the NSTableView (NSControl) All other key events ...
Marek H's user avatar
  • 5,652
1 vote
1 answer
231 views

I am reading the keyboard shortcuts typed inside a NSTextField. When I press, for example, shift + option + F2, this method class func convertToString(event:NSEvent) -> String { var shortcut = ""...
Duck's user avatar
  • 36.2k
0 votes
1 answer
270 views

I am trying to bring to foreground a NSRunningApplication* instance, and inject a keyboard event. NSRunningApplication* app = ...; [app activateWithOptions: 0]; inject_keystrokes(); ... fails to ...
P i's user avatar
  • 31.3k
0 votes
1 answer
299 views

I have the following Objective-C snippet: void toggle() { NSEvent* down_event = [NSEvent keyEventWithType: NSEventTypeKeyDown location: NSZeroPoint ...
P i's user avatar
  • 31.3k
0 votes
1 answer
321 views

I am trying to capture a screenshot by posting this Keyboard event. I tried below way which doesn't work: 1] CGEventRef event1, event2, event3, event4, event5, event6; event1 = ...
Sukeshj's user avatar
  • 1,503
1 vote
1 answer
1k views

In Xcode 10.1 with Swift 4.2 I'm having a memory leak when I add a local monitor for key down events in my NSViewController, that it is be instanced as minimal version (without nib and xib). override ...
Jesús Mateos Gomez's user avatar
0 votes
0 answers
225 views

I'm using a local monitor to observe key events. However, I get an incorrect keycode when the modifiers ⌥ and ⌘ are active and the key with code 42 is pressed simultaneously. The keyCode in the event ...
PeteSabacker's user avatar
3 votes
1 answer
491 views

When "tap to click" checked, how judge NSEvent is from trackpad click(pressed down) or tap to click. - (void)mouseEvent:(NSEvent*)theEvent {   if ((type == NSLeftMouseUp || type == NSLeftMouseDown) &...
章清照's user avatar
3 votes
1 answer
2k views

Here again with another memory leak issue. I have an NSStatusItem that I'm trying to capture mouse clicks on and react. The following code causes Instruments to report a leak and removing this code ...
William Gustafson's user avatar
0 votes
1 answer
107 views

I subclass an NSScrollView to monitor 2-finger panning with touchesBegan/Moved/Ended. It works as long as I click on the view once after the app is launched. Then it will always work till the next ...
honcheng's user avatar
  • 2,044
0 votes
0 answers
49 views

I am trying to capture cmd - and cmd + key presses in Swift, cmd - works fine but when pressing cmd + I get an error bong sound. override func keyDown(with event: NSEvent) { if event....
BenJacob's user avatar
  • 1,017
-1 votes
1 answer
169 views

I am learning swift and I am trying to make a simple app where I move an object (The default ship) with the keyboard. I am designing an event to represent the left keypress. Since I do not need the ...
Louis Couture's user avatar
0 votes
1 answer
449 views

I'm trying to create a small WASD demo game in macOS. I'm using NSEvent for handling the key events. To detect the key presses, I'm searching for keyDown events. Here's what I have: NSEvent....
Adil Patel's user avatar
1 vote
0 answers
374 views

I am trying to monitor mouse click events like so: clickMonitor = NSEvent.addGlobalMonitorForEvents( matching: [.leftMouseDown, .rightMouseDown, .leftMouseUp, .rightMouseUp]) { [unowned self] ...
the_br's user avatar
  • 11
1 vote
0 answers
374 views

In building a custom NSButton, I've run into a problem handling highlight behavior. After clicking down on the button, holding, and dragging the cursor outside the button's bounds, mouseExited: and ...
Jordan H's user avatar
  • 56.5k
-1 votes
1 answer
183 views

Is there a way to track the time between a mouseDown and a mouseUp event in swift? Or would one have to implement their own tracker manually?
Joel Tecson's user avatar
5 votes
1 answer
3k views

I'm working on a MacOS menu bar app which needs to track some global shortcuts in order to facilitate adjusting display brightness on external monitors. However, I cannot get it to fire a handler on ...
CatalinM's user avatar
  • 580

1
2 3 4 5