I am having multiple controls like NSTextfields and NSButtons. I couldn't find a solution for touch up inside events in swift 2.2. I tried it with the new selectors but I don't know how to handle touch events with them... Here is my code:
override func viewDidLoad() {
textfield.action = #selector(myAction)
button.action = #selector(myAction)
}
func myAction(sender: NSView)
{
print("aktuell: \(sender)")
currentObject = sender
}
I am not familiar with the new version of Swift 2.2 so I have no idea how to handle the touch events. I also tried to handle it over the delegate methods but this also didn't work because I have no method for the control if its being touched.
In the older versions of swift I had something like:
button.addTarget(self, action: Selector("actionMethod"), forControlEvents: UIControlEvents.TouchUpInside)
Error when trying to add the addTarget
function:
Value of type 'NSButton' has no member 'addTarget'
But I can't find this in swift 2.2 and there is an error if I am trying to use it. Thanks for help!
I am using OSX not iOS but this should be the same...