Place the comment in the right place in DetailWebView.

This commit is contained in:
Brent Simmons 2019-02-12 22:56:44 -08:00
parent bdf94c21f0
commit 2f8bee998e
1 changed files with 8 additions and 8 deletions

View File

@ -9,19 +9,17 @@
import AppKit
import WebKit
// Theres no API for affecting a WKWebViews contextual menu.
// (WebView had API for this.)
//
// This a minor hack. It hides unwanted menu items.
// The menu item identifiers are not documented anywhere;
// they could change, and this code would need updating.
final class DetailWebView: WKWebView {
// MARK: NSView
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
// Theres no API for affecting a WKWebViews contextual menu.
// (WebView had API for this.)
//
// This a minor hack. It hides unwanted menu items.
// The menu item identifiers are not documented anywhere;
// they could change, and this code would need updating.
for menuItem in menu.items {
if shouldHideMenuItem(menuItem) {
menuItem.isHidden = true
@ -47,6 +45,8 @@ final class DetailWebView: WKWebView {
}
}
// MARK: - Private
private extension NSUserInterfaceItemIdentifier {
static let DetailMenuItemIdentifierReload = NSUserInterfaceItemIdentifier(rawValue: "WKMenuItemIdentifierReload")