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
5
votes
2 answers

Discard mouse events on NSWindow based on click position

Let's say I have a floating, borderless, circular NSWindow. It is circular because the content view simply draws a red circle. That content view needs to be layer-backed ([contentView setWantsLayer:YES]), because I'm applying CoreAnimations on it,…
Raffael
  • 1,119
  • 10
  • 20
5
votes
1 answer

How to detect key up or key release for the capslock key in OS X?

I'm having a problem with OS X detecting keystrokes. I need to detect a key down AND a key release or key up whenever a keyboard key is pressed. This is fairly straight-forward when intercepting the application's event handling chain with [ NSEvent…
Ted Middleton
  • 6,859
  • 10
  • 51
  • 71
4
votes
0 answers

NSEvent global event monitoring of modifier flags returns mixed results

A peculiar issue is popping up with regards to global monitoring of modifier flag changes. Assume the monitor is as below... _flagsChangedGlobalEventHandler = [NSEvent addGlobalMonitorForEventsMatchingMask:NSFlagsChangedMask handler:^(NSEvent…
the979kid
  • 635
  • 5
  • 15
4
votes
3 answers

NSOpenGLView, NSWindow & NSResponder - makeFirstResponder not working

In the code below I am Initialising a NSViewController [a NSResponder], with a NSWindow, a NSOpenGLView, presenting the view and attempting to set the NSViewController as the windows first responder. It is not working. I was expecting to be able to…
Seamus
  • 1,107
  • 10
  • 22
4
votes
1 answer

Keep mouse within area in Swift

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.addGlobalMonitorForEvents(matching: [.mouseMoved,…
mxrlkn
  • 83
  • 7
4
votes
3 answers

mouseEntered event disabled when mouseDown (NSEvents Mac)

I have created an NSButton class, and when rolling over my buttons it happily detects mouseEntered and mouseExited events. But as soon as the mouseDown event occurs, so long as the mouse it down, mouseEntered events are no longer called until the…
Josh Kahane
  • 16,765
  • 45
  • 140
  • 253
4
votes
2 answers

how to handle key events in iphone

Hi I am working on an iphone application and want to handle keyboard events in iphone. In Mac, there is a class NSEvent which handles both keyboard and mouse events, and in ios (iphone/ipad) the counterpart of NSEvent is UIEvent which handles only…
aqavi_paracha
  • 1,131
  • 2
  • 17
  • 38
4
votes
0 answers

How to create my own modifier key using HID on OSX Sierra

Recently Karabiner (the great OSX remapping tool) stopped working on Sierra. I just read that it is possible to remap keys with HID and I tried the example code below, which remaps a and b. However it's not clear how to create my own modifier key…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
4
votes
1 answer

Position of mouse click relative to scene, not window

In my game I need to use the mouse to select units. However, I am encountering problems as I do not know how to get the coordinates of the click relative to the game, not to the window. For example, if Unit 1 is at the (0,0) point of the game, it…
Student-LTB
  • 103
  • 8
4
votes
1 answer

Move four Rectangle's points simultaneously

I'm developing a macOS app that generates rectangles. I can separately move rectangles' points with left mouse button LMB. The principle of operation: when I drag 1 point with a LMB, the other 3 points will follow it at the same time with the same…
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
4
votes
3 answers

NSButton Mousedown event

I'm trying to show a pop up menu on mouse down on a button. The button should appear pressed while mouse down, and be "un pressed" on mouse up regardless of any of the menu item been selected. Similar to the Expose/Space Preference panel "+" button…
Dan
  • 1,711
  • 1
  • 22
  • 36
4
votes
2 answers

NSEvent `subtype` equivalent for CGEvent?

NSEvent has a method to get the event's subtype: Getting Custom Event Information – data1 – data2 – subtype Can this same subtype be accessed from a CGEvent without first converting it to an NSEvent? CGEventRef eventCG = ...; NSEvent…
pkamb
  • 33,281
  • 23
  • 160
  • 191
4
votes
3 answers

Getting Key down event in an NSView controller

I'm trying to find a solution that allows me to get keydown events in a view controller. I do not believe a view controller is part of the responder chain by default. I would appreciate a sample of how to go about this. I have had trouble finding…
Miek
  • 1,127
  • 4
  • 20
  • 35
4
votes
1 answer

Toggling the selected state of a TableView cell with the mouse

By default, NSTableView allows the user to clear the rows selection by clicking anywhere in the blank area of the table view. This however is not always intuitive and sometimes isn’t even possible (for example, when the table view doesn’t actually…
Arnold
  • 2,390
  • 1
  • 26
  • 45
4
votes
2 answers

How to catch 1 tap with 3 fingers (NSEvent) on a custom NSView?

I have to following code to catch mouseDowns on my custom NSView but I think this only catches how many taps (using the clickCount), not how many fingers were used to tap: - (void)updateTrackingAreas{ if(trackingArea != nil) { [self…
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
1 2
3
14 15