Make NSMenuItem _setViewHandlesEvents public API or provide an adequate alternative
| Originator: | mgoszcz2 | ||
| Number: | rdar://34084074 | Date Originated: | 2017-08-25 |
| Status: | Duplicate | Resolved: | Duplicate of 22648078 |
| Product: | macOS, AppKit | Product Version: | macOS 10.12 |
| Classification: | Suggestion | Reproducible: | N/A |
Developing custom menu items is complex. While well intended, delegating event tracking to the custom view results in developers relying on implementation detail to make the menus appear native. Examples: - Assuming each NSMenuItem view is contained by an NSVisualEffectView [1]. - Neglecting important aspects of the menu interface such as changing selection using arrow keys - Native look is non-trivial to achieve (https://stackoverflow.com/questions/26851306/) Custom menu items appear split into two categories. Those that need completely custom behaviour like the Help menu and those that use custom views to provide layout not expressible by standard NSMenuItems such as the WiFi network selection. Digging through SystemUIServices, AirPort Menu Extra and CoreWLANKit I found the currently private _setViewHandlesEvent method. I counted ~16 uses of _setViewHandlesEvent on my system including Safari, Xcode as well AirPort, User and Battery menu extras. However exposing _setViewHandlesEvent might not necessarily be the best option. With context sensitive NSColors such as labelColor and template images a better API could be developed to remove the burden of manipulating text and image colours. Expected Results: Making simple custom menu items should be simple and relatively future-proof. Observed Results: Making simple custom menu items requires hacks, is not future-proof and interacts sub-optimally with other menu items. [1]: https://github.com/kaush012/CustomMenuItem/blob/ea5b9823466c7e6f59c2b8408df4373f21be3843/VisualEffectView/CustomView.swift#L95
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!