Place the comment in the right place in DetailWebView.
This commit is contained in:
parent
bdf94c21f0
commit
2f8bee998e
|
@ -9,19 +9,17 @@
|
||||||
import AppKit
|
import AppKit
|
||||||
import WebKit
|
import WebKit
|
||||||
|
|
||||||
|
final class DetailWebView: WKWebView {
|
||||||
|
|
||||||
|
// MARK: NSView
|
||||||
|
|
||||||
|
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
|
||||||
// There’s no API for affecting a WKWebView’s contextual menu.
|
// There’s no API for affecting a WKWebView’s contextual menu.
|
||||||
// (WebView had API for this.)
|
// (WebView had API for this.)
|
||||||
//
|
//
|
||||||
// This a minor hack. It hides unwanted menu items.
|
// This a minor hack. It hides unwanted menu items.
|
||||||
// The menu item identifiers are not documented anywhere;
|
// The menu item identifiers are not documented anywhere;
|
||||||
// they could change, and this code would need updating.
|
// they could change, and this code would need updating.
|
||||||
|
|
||||||
final class DetailWebView: WKWebView {
|
|
||||||
|
|
||||||
// MARK: NSView
|
|
||||||
|
|
||||||
override func willOpenMenu(_ menu: NSMenu, with event: NSEvent) {
|
|
||||||
|
|
||||||
for menuItem in menu.items {
|
for menuItem in menu.items {
|
||||||
if shouldHideMenuItem(menuItem) {
|
if shouldHideMenuItem(menuItem) {
|
||||||
menuItem.isHidden = true
|
menuItem.isHidden = true
|
||||||
|
@ -47,6 +45,8 @@ final class DetailWebView: WKWebView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Private
|
||||||
|
|
||||||
private extension NSUserInterfaceItemIdentifier {
|
private extension NSUserInterfaceItemIdentifier {
|
||||||
|
|
||||||
static let DetailMenuItemIdentifierReload = NSUserInterfaceItemIdentifier(rawValue: "WKMenuItemIdentifierReload")
|
static let DetailMenuItemIdentifierReload = NSUserInterfaceItemIdentifier(rawValue: "WKMenuItemIdentifierReload")
|
||||||
|
|
Loading…
Reference in New Issue