AcceptsFirstResponder in NSViewController and xcode 6 - Swift

Can someone explain to me how I can set acceptsFirstResponder to NSViewController in Swift and xcode 6?

The program does not allow overriding the function and says that it does not exist in the superclass, but I also can not set it as a variable of the type:

self.acceptsFirstResponder = true 

Somebody knows?

+5
source share
1 answer

I had a similar problem, but with the NSView class. I was able to make this work as follows. I had to put it in a class outside of any functions.

 import Cocoa class MyView: NSView, NSDraggingDestination { //MARK: Variables override var acceptsFirstResponder: Bool { return true } override var opaque: Bool { return true } var bgColor : NSColor = .yellowColor() var lastString : String = "" var attributes : NSMutableDictionary = [:] var highlightNeeded = false 
+7
source

Source: https://habr.com/ru/post/1201783/


All Articles