I would like to create a popup menu using swift coding in a macOS app from a right click event using Xcode 11 or 12. Can't seem to find an example of this. I see plenty of IOS examples but none for macOS. Does anyone have an example of this you could share or could show me how this is done.
Also, I know how to add a menu to to the View Controller but this allows right click from anywhere in the tableView and I want the popup menu to show when you right click on a row in the table. If anybody is familiar with quicken for Mac I want the same function as it as when you right click on a row in an account register.
Here is the code for the right click event:
I have ask this question on couple of other forums as well as searched for tutorials on this and have come up empty.
Also, I know how to add a menu to to the View Controller but this allows right click from anywhere in the tableView and I want the popup menu to show when you right click on a row in the table. If anybody is familiar with quicken for Mac I want the same function as it as when you right click on a row in an account register.
Here is the code for the right click event:
Code Block // right click action override func rightMouseDown(with theEvent: NSEvent) { let point = tableView.convert(theEvent.locationInWindow, from: nil) let row = tableView.row(at: point) selectedCustomer = custviewModel.customers[row].custNumber! print(selectedCustomer) // Add popup menu print("right click") print(row) }
I have ask this question on couple of other forums as well as searched for tutorials on this and have come up empty.