Cocoa NSTableView multiple choice without command key

Is there a way to achieve multiple selection behavior in an NSTableView without requiring the user to hold the command button on click? This was easy to do in the Carbon, ORing list box in the cmdKey modifier flag during mouse processing when calling the HandleControlClick () function. I am new to Cocoa and I don’t understand how I can easily modify the event programmatically or if this is the best solution.

+3
source share
1 answer

Subclass NSTableView and make the lookup table an instance of this subclass. In the subclass, respond to mouseDown:and mouseUp:by creating a new mouse event based on the one you received, only with the NSCommandKeyMaskORed flag in the modifier flags and passing the new event to super.

However, I hope it will be obvious to your user that they can select multiple items. Also, don't break the Shift key - make sure continuous selection still works.

+4
source

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


All Articles