Questions tagged [nsresponder]

NSResponder is a class used in Mac Development. NSResponder is an abstract class that forms the basis of event and command processing in the Application Kit. The core classes—NSApplication, NSWindow, and NSView—inherit from NSResponder, as must any class that handles events. The responder model is built around three components: event messages, action messages, and the responder chain.

106 questions
3
votes
1 answer

KeyEvents in Cocoa and XCode

I'm learning Objective-C by building a basic calculator app for OSX. Everything works beautifully, except I need to allow pressing of certain keys on the keyboard to do the same thing as if you clicked the buttons on the interface. Everything I read…
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
2
votes
1 answer

Objective-C: Detecting "shift" keypress while another key is pressed

This is to implement a keyboard based game controller. Left/Right arrows makes the character walk. shift+left/right makes the character run. Here's the code I'm using so far: - (void)keyDown:(NSEvent *)event{ if ([event modifierFlags] &…
Jem
  • 6,226
  • 14
  • 56
  • 74
2
votes
1 answer

Cocoa NSApplication not active but receiving mouse events

I'm having a weird issue where I click away from my window. It resigns main and key. Then I click back to it and the view that was clicked on does not respond to the mouse click. But the second click does cause the view to respond. As if during…
Larvell Jones
  • 159
  • 2
  • 15
2
votes
3 answers

mouseMoved not called when over the View

I have subclass of NSView which implements mouseMoved. However when I move my mouse over the view the mouseMoved never gets called. Why? I am on OS X Lion. Thanks, Vance
jox
  • 74
  • 2
  • 8
2
votes
1 answer

How do I connect storyboard to swiftui?

How do I connect the storyboard to swiftUI? I have tried to go to the finder/editor/assistant but it takes me to 'NSResponder.h' Is this the right place to connect code and storyboard in a Mac OS application? If so where in said file? If not what do…
Grompy
  • 91
  • 1
  • 2
  • 3
2
votes
1 answer

How to capture escape key in an NSWindow?

I've got a storyboard with an NSWindowController (the storyboard entry point), whose content is an NSViewController. When the user selects a menuitem in my application, I load the storyboard and display it. Now I want the "escape" key to close the…
Tiny Tim
  • 21
  • 2
2
votes
2 answers

Can underline, but not bold text in NSTextView

I have an NSDocuments & storyboard app created with the wizard in Xcode 8. In the ViewController Scene I have added a NSTextView. Certain menu items are disabled, such as Bold and Italic. Looking at the First Responder the actions for bold and…
Henrik
  • 3,908
  • 27
  • 48
2
votes
1 answer

How to update NSResponder selector in swift 2.2

I am implementing a NSControlTextEditingDelegate protocol and I don't know which class/protocol i should match with e.g. commandSelector. #selector(WhichClass.moveUp(_:)) so that the equality will pass. Currently everything is ok with swift…
Marek H
  • 5,173
  • 3
  • 31
  • 42
2
votes
1 answer

What changed the next responder of my NSWindow?

I'm trying to debug an issue caused by the change of a next responder of the main NSWindow. I have an internal NSView and a chain of custom NSResponder, however even after debugging and sticking breakpoints all over every setNextResponder, I never…
Stan
  • 57
  • 5
2
votes
0 answers

Where are SKNode positioned in the responder chain?

SKNode inherits from NSResponder but I'm having trouble understanding how nodes are included in the responder chain and where they are inserted. For example, how does a SKNode receive the mouseDown: message? When a view is clicked, a hit testing…
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
2
votes
3 answers

UIView superview added on self.view returns nil

I check if view is already added/exist, then I need to remove it if([self.upgradeView superview]) [self.upgradeView removeFromSuperview]; self.upgradeView is added on self.view. but condition returns false and self.upgradeView is never…
Praful Kadam
  • 372
  • 6
  • 22
2
votes
1 answer

Is it possible to override the user KeyBindings with app-specific ones on a mac?

The user specific keyBindings .dict file is found in: ~/Library/KeyBindings/ How can you (as the developer) tell AppKit to look in another directory (app specific) for another bindings file for your specific application. This does not need to…
Sam
  • 2,745
  • 3
  • 20
  • 42
2
votes
2 answers

NSResponder resignFirstResponder fires on wrong object

I have a Mac application (SDK 10.10) with some NSTextFields: Since I need to get notified when a text field gets and resigns focus, I subclassed NSTextField: @interface MyTextField : NSTextField @end @implementation MyTextField -…
Zaggo
  • 786
  • 1
  • 6
  • 14
2
votes
1 answer

Detect/check character sequence in NSView (NSResponder)

Requirement I'd like to detect not a single but a sequence of characters to trigger an action, e.g when the user types 'cat' into a NSView subclass - but not for a 'c'. Is there anything smarter other than maintaining something like a NSMutableArray…
cacau
  • 3,606
  • 3
  • 21
  • 42
2
votes
0 answers

-swipeWithEvent: not called until a two-finger scroll occurs

I have a NSView subclass inside an NSScrollView that implements -swipeWithEvent. I've noticed that swipeWithEvent: is never called until the user first performs a two-finger scroll on the trackpad. After that, it works consistently. What could…
George
  • 1,265
  • 1
  • 10
  • 8