Reputation: 946
I've created a Main Menu item for File, called Refresh, mapped CMD-R to it. But for some reason, the Main Menu item is disabled, when launching the app.
But when I launch the app, the main menu shows the Refresh item as disabled. When I click on WKWebView view and press CMD-R, and then open the main menu, the Refresh item is enabled.
How do I make the Refresh item enabled by default?
EDIT: One very interesting detail: The minute I click on the WKWebView - the Refresh-item becomes active. So, should I have done this in a different way? I currently have it linked like this:
Refresh Menu Item linked to First Responder, with reloadFromOrigin:
selected.
Upvotes: 4
Views: 2061
Reputation: 257711
Menu items are validated by FirstResponder. When application just started the first responder in your case, seems main window and below by responder chain, does not have implemented selector of that menu item (probably, reload(_:)
), so menu item is disabled.
When you click on WKWebView it becomes first responder and menu item becomes enabled, because it has implemented reload(_:)
selector.
So you need to implement reload(_:)
selector either in overridden root view controller or in AppDelegate and do in it what's needed.
Upvotes: 2