validateContextMenuItem(withCommand:in:userInfo:validationHandler:)
Validates whether a particular contextual menu item should be displayed.
Declaration
optional func validateContextMenuItem(withCommand command: String, in page: SFSafariPage, userInfo: [String : Any]? = nil, validationHandler: @escaping (Bool, String?) -> Void)Parameters
- command:
The command, specified in the
Info.plistfile, for the context menu item being validated. - page:
The page where the context menu item is going to be presented.
- userInfo:
Optional message content. If specified, the dictionary’s value objects conform to the W3C standard for safe passing of structured data, such as Boolean objects, numeric values, strings, and arrays.
- validationHandler:
A code block used to set the state of the contextual menu item. The block receives the following parameters:
- shouldHide
A Boolean value that indicates whether the menu item should be hidden.
- text
The text to use for the menu item. Pass
nilto use the default text from theInfo.plistfile.
Mentioned in
Discussion
If you do not implement this method, the contextual menu item is always available. Otherwise, this method is called before the contextual menu is shown so that you can determine whether the menu item should be displayed and the text that appears in the item.
To hide the contextual menu item:
To change the menu text:
To use the default text: