Mac Developer Library

Developer

WebKit Framework Reference WebUIDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

WebUIDelegate

Web view user interface delegates implement this informal protocol to control the opening of new windows, augment the behavior of default menu items displayed when the user clicks elements, and perform other user interface–related tasks. These methods can be invoked as a result of handling JavaScript or other plug-in content. Delegates that display more than one web view per window, for example, need to implement some of these methods to handle that case. The default implementation assumes one window per web view, so non-conventional user interfaces might implement a user interface delegate.

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import WebKit

Objective-C

@import WebKit;

Availability


Available in OS X v10.2 with Safari 1.0 and later.
Available in OS X v10.2.7 and later.
  • Creates a modal window containing a web view that loads the specified request.

    Declaration

    Swift

    func webView(_ sender: WebView!, createWebViewModalDialogWithRequest request: NSURLRequest!) -> WebView!

    Objective-C

    - (WebView *)webView:(WebView *)sender createWebViewModalDialogWithRequest:(NSURLRequest *)request

    Parameters

    sender

    The web view that sent the message.

    request

    The request to load.

    Return Value

    The web view that is loading the specified request.

    Discussion

    This method is invoked when JavaScript calls window.showModalDialog. It should create a new modal window containing the web view and initially hide the window. The webViewRunModal: message is sent to the delegate to display the web view.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Displays a web view in a modal window.

    Declaration

    Swift

    func webViewRunModal(_ sender: WebView!)

    Objective-C

    - (void)webViewRunModal:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Discussion

    This method should display and order front a modal window containing the specified web view. This method is invoked after the webView:createWebViewModalDialogWithRequest: method is used to create a new window.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Creates a window containing a web view to load the specified request.

    Declaration

    Swift

    func webView(_ sender: WebView!, createWebViewWithRequest request: NSURLRequest!) -> WebView!

    Objective-C

    - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request

    Parameters

    sender

    The web view that sent the message.

    request

    The request to load.

    Return Value

    The web view that is loading the request.

    Discussion

    This method should begin loading the content for the specified request by sending loadRequest: to its main frame. The new window should initially be hidden. Later, a webViewShow: message is sent to the delegate of the new web view. By default, this method returns nil.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Closes a web view in a window.

    Declaration

    Swift

    func webViewClose(_ sender: WebView!)

    Objective-C

    - (void)webViewClose:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Discussion

    If you display multiple web views in a window then you might want to close only sender in your implementation. By default, this method sends the close method to the NSWindow object that contains sender.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns a Boolean value indicating whether a web view’s window can be resized.

    Declaration

    Swift

    func webViewIsResizable(_ sender: WebView!) -> Bool

    Objective-C

    - (BOOL)webViewIsResizable:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    YEStrue if the web view’s window can be resized; otherwise, NOfalse.

    Discussion

    If you display multiple web views in a window then your user interface delegate should implement this method to handle this special case.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets whether a web view’s window can be resized.

    Declaration

    Swift

    func webView(_ sender: WebView!, setResizable resizable: Bool)

    Objective-C

    - (void)webView:(WebView *)sender setResizable:(BOOL)resizable

    Parameters

    sender

    The web view that sent the message.

    resizable

    If YEStrue, the web view’s window can be resized; if NOfalse, the window is not resizable.

    Discussion

    By default, this method sets the window containing a web view to be resizable. If you display multiple web views in a window then your user interface delegate should implement this method to handle this special case. If you do not implement this method, the NSWindow method setShowsResizeIndicator: is sent to the window that contains sender.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the frame rectangle of a web view’s window to the specified frame size.

    Declaration

    Swift

    func webView(_ sender: WebView!, setFrame frame: NSRect)

    Objective-C

    - (void)webView:(WebView *)sender setFrame:(NSRect)frame

    Parameters

    sender

    The web view that sent the message.

    frame

    The frame size.

    Discussion

    The sender invokes this method instead of setting the window’s frame directly, allowing delegates to augment the behavior by, for example, saving the original window size before resizing as a result of JavaScript running. If you do not implement this method, the NSWindow method setFrame:display: is sent to the window that contains sender, with YEStrue passed as the display argument.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the frame rectangle of a web view’s window.

    Declaration

    Swift

    func webViewFrame(_ sender: WebView!) -> NSRect

    Objective-C

    - (NSRect)webViewFrame:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The frame rectangle of the web view’s window.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the window’s content view frame to the specified content rectangle.

    Deprecation Statement

    Content rectangle calculations are automatic.

    Declaration

    Objective-C

    - (void)webView:(WebView *)sender setContentRect:(NSRect)contentRect

    Parameters

    sender

    The web view that sent the message.

    contentRect

    The location and size of the window’s content area.

    Discussion

    The content view is the highest accessible NSView object in the view hierarchy displayed in the window. A web view invokes this method instead of setting the content view’s frame directly, allowing delegates to augment the behavior by, for example, avoiding auto-saving of the size.

    If this method is not implemented by the delegate, then webView:setFrame: is invoked with the rectangle returned by sending the NSWindow method frameRectForContentRect:styleMask: to the window.

    Import Statement

    Objective-C

    @import WebKit;

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

    Deprecated in OS X v10.4.11.

  • Returns a web view window's content rectangle.

    Deprecation Statement

    Content rectangle calculations are automatic.

    Declaration

    Objective-C

    - (NSRect)webViewContentRect:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The content rectangle of the window that contains the web view.

    Discussion

    The content view is the highest accessible NSView object in the view hierarchy displayed in the window. A web view invokes this method instead of setting the content view’s frame directly, allowing delegates to alter the size that is returned.

    Import Statement

    Objective-C

    @import WebKit;

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

    Deprecated in OS X v10.4.11.

  • Brings a web view’s window to the front and makes it the active window.

    Declaration

    Swift

    func webViewFocus(_ sender: WebView!)

    Objective-C

    - (void)webViewFocus:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Discussion

    By default, this method brings a web view's window into focus. If you display multiple web views in a window then you might also want to focus the input on sender, using webView:makeFirstResponder:.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Relinquishes focus on a web view’s window.

    Declaration

    Swift

    func webViewUnfocus(_ sender: WebView!)

    Objective-C

    - (void)webViewUnfocus:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Discussion

    This method releases focus for the entire window. If you display multiple web views in a window, you might instead want to change the input focus to another view, using the webView:makeFirstResponder: method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Displays a web view’s window and moves it to the front.

    Declaration

    Swift

    func webViewShow(_ sender: WebView!)

    Objective-C

    - (void)webViewShow:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Discussion

    This method is typically used after a call to webView:createWebViewWithRequest:, which creates a new window. The new window is not ordered to the front (or even shown) unless you implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the first responder of the web view’s window.

    Declaration

    Swift

    func webViewFirstResponder(_ sender: WebView!) -> NSResponder!

    Objective-C

    - (NSResponder *)webViewFirstResponder:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The view or subview that currently has the input focus. It can return nil or the default first responder if the sender is not attached to a window or if another view (not in the window) has the focus.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the first responder of a web view’s window to the specified view.

    Declaration

    Swift

    func webView(_ sender: WebView!, makeFirstResponder responder: NSResponder!)

    Objective-C

    - (void)webView:(WebView *)sender makeFirstResponder:(NSResponder *)responder

    Parameters

    sender

    The web view that sent the message.

    responder

    A view in the web view’s hierarchy.

    Discussion

    You can ignore this message if sender is not yet attached to a window.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Updates information about the element the user is mousing over.

    Declaration

    Swift

    func webView(_ sender: WebView!, mouseDidMoveOverElement elementInformation: [NSObject : AnyObject]!, modifierFlags modifierFlags: Int)

    Objective-C

    - (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(NSUInteger)modifierFlags

    Parameters

    sender

    The web view that sent the message.

    elementInformation

    A dictionary that describes the element under the mouse, or nil. See “Constants” in WebView Class Reference for information about the key-value pairs in this dictionary.

    modifierFlags

    An integer bit field that indicates the modifier keys in effect during the event. See “Modifier Flags” in NSEvent Class Reference for information about possible modifiers. Note that this parameter was changed from an unsigned int to an NSUInteger in OS X v10.5.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns menu items to display in an element's contextual menu.

    Declaration

    Swift

    func webView(_ sender: WebView!, contextMenuItemsForElement element: [NSObject : AnyObject]!, defaultMenuItems defaultMenuItems: [AnyObject]!) -> [AnyObject]!

    Objective-C

    - (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems

    Parameters

    sender

    The web view that sent the message.

    element

    A dictionary that describes the element that was clicked. See “Constants” in WebView Class Reference for information about the key-value pairs in this dictionary.

    defaultMenuItems

    The menu items included by default in the element’s contextual menu. See Menu Item Tags for values you can use to differentiate among specific menu items.

    Return Value

    An array of menu items to display in the element’s contextual menu.

    Discussion

    This method is invoked every time the user clicks the right mouse button, or control-clicks, on an element to reveal a contextual menu. The receiver typically returns a modified copy of the default menu items dictionary, adding and removing menu items as appropriate for this type of element. You can use this mechanism to remove items that are not appropriate for a particular environment or task, such as saving files to the desktop in a web kiosk. You do not need to set the actions and targets of the default items.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the status message displayed by a web view’s window, if any, to the specified text.

    Declaration

    Swift

    func webView(_ sender: WebView!, setStatusText text: String!)

    Objective-C

    - (void)webView:(WebView *)sender setStatusText:(NSString *)text

    Parameters

    sender

    The web view that sent the message.

    text

    The status message to display.

    Discussion

    The delegate receives this message when a JavaScript function in the web view explicitly sets the status text. No action is taken if you do not implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns the current status message from a web view's window.

    Declaration

    Swift

    func webViewStatusText(_ sender: WebView!) -> String!

    Objective-C

    - (NSString *)webViewStatusText:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The status message displayed in the web view’s window if one has been set with the webView:setStatusText: method; otherwise, nil.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns a Boolean value indicating whether any toolbars are visible in a web view's window.

    Declaration

    Swift

    func webViewAreToolbarsVisible(_ sender: WebView!) -> Bool

    Objective-C

    - (BOOL)webViewAreToolbarsVisible:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    YEStrue if a web view’s window has any toolbars that are currently visible (other than the status bar); otherwise, NOfalse.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets whether a web view's toolbars should be visible.

    Declaration

    Swift

    func webView(_ sender: WebView!, setToolbarsVisible visible: Bool)

    Objective-C

    - (void)webView:(WebView *)sender setToolbarsVisible:(BOOL)visible

    Parameters

    sender

    The web view that sent the message.

    visible

    If YEStrue, all toolbars (with the exception of the status bar) are shown; otherwise, all toolbars (with the exception of the status bar) are removed.

    Discussion

    No action is taken if you do not implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns a Boolean value indicating whether the status bar in a web view's window is visible.

    Declaration

    Swift

    func webViewIsStatusBarVisible(_ sender: WebView!) -> Bool

    Objective-C

    - (BOOL)webViewIsStatusBarVisible:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    YEStrue if a web view's status bar (if any) is visible; otherwise, NOfalse.

    Discussion

    If you do not implement this method, it returns NOfalse by default.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Sets the visibility of the status bar in a web view’s window.

    Declaration

    Swift

    func webView(_ sender: WebView!, setStatusBarVisible visible: Bool)

    Objective-C

    - (void)webView:(WebView *)sender setStatusBarVisible:(BOOL)visible

    Parameters

    sender

    The web view that sent the message.

    visible

    If YEStrue, the delegate should display the status bar (if any); if NOfalse, the delegate should hide the status bar.

    Discussion

    No action is taken if you do not implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.2 with Safari 1.0 and later.

    Available in OS X v10.2.7 and later.

  • Returns a mask indicating which drag operations are allowed by the sender.

    Declaration

    Swift

    func webView(_ sender: WebView!, dragDestinationActionMaskForDraggingInfo draggingInfo: NSDraggingInfo!) -> Int

    Objective-C

    - (NSUInteger)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo:(id<NSDraggingInfo>)draggingInfo

    Parameters

    sender

    The web view that sent the message.

    draggingInfo

    The information object for the dragging operation.

    Return Value

    A mask that indicates which drag operations are allowed when content is dragged over the sending web view. (Note that the return value changed from an unsigned int to an NSUInteger in OS X v10.5.) See Drag-Destination Actions for a list of return values.

    Discussion

    This method can be invoked multiple times while content is dragged over the sending web view. When the content is dropped, the web view sends a notification (webView:willPerformDragDestinationAction:forDraggingInfo:) to the receiver.

    If you do not implement this method, it returns WebDragDestinationActionAny by default.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Returns a mask indicating which drag-source actions are allowed for a drag that begins at the specified location.

    Declaration

    Swift

    func webView(_ sender: WebView!, dragSourceActionMaskForPoint point: NSPoint) -> Int

    Objective-C

    - (NSUInteger)webView:(WebView *)sender dragSourceActionMaskForPoint:(NSPoint)point

    Parameters

    sender

    The web view that sent the message.

    point

    The point at which the drag began, specified in the coordinates of the web view.

    Return Value

    A mask indicating which drag-source actions are allowed. (Note that the return value changed from an unsigned int to an NSUInteger in OS X v10.5.) See Drag-Source Actions for a list of return values.

    Discussion

    This method is called after the user has begun a drag from a point in a web view. This method can be invoked multiple times while content is dragged from the sending web view. When the content is dropped, the sender sends webView:willPerformDragSourceAction:fromPoint:withPasteboard: to the receiver.

    If you do not implement this method, it returns (WebDragSourceActionAny & ~WebDragSourceActionLink) if the cursor is in an editable part of the web view; otherwise, it returns WebDragDestinationActionAny.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Tells the receiver that the sending web view will perform the specified drag-destination action.

    Declaration

    Swift

    func webView(_ sender: WebView!, willPerformDragDestinationAction action: WebDragDestinationAction, forDraggingInfo draggingInfo: NSDraggingInfo!)

    Objective-C

    - (void)webView:(WebView *)sender willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id<NSDraggingInfo>)draggingInfo

    Parameters

    sender

    The web view that sent the message.

    action

    The drag-destination action to perform. See Drag-Destination Actions for a list of actions.

    draggingInfo

    The information object for the dragging operation.

    Discussion

    This method is invoked after the last invocation of the webView:dragDestinationActionMaskForDraggingInfo: method, when the dragged content is dropped and the sender is about to perform the destination action. No action is taken if you do not implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Tells the receiver that the sending web view will perform the specified drag-source action.

    Declaration

    Swift

    func webView(_ sender: WebView!, willPerformDragSourceAction action: WebDragSourceAction, fromPoint point: NSPoint, withPasteboard pasteboard: NSPasteboard!)

    Objective-C

    - (void)webView:(WebView *)sender willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard

    Parameters

    sender

    The web view that sent the message.

    action

    The drag-source action to perform. See Drag-Source Actions for a list of actions.

    point

    The point at which the drag began, specified in the coordinates of the web view.

    pasteboard

    The drag pasteboard.

    Discussion

    This method is invoked after the last invocation of the webView:dragSourceActionMaskForPoint: method, when the dragged content is dropped and the sender is about to perform the drag-source action. The delegate has the opportunity to modify the contents of the object on the pasteboard before completing the drag-source action. No action is taken if you do not implement this method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Returns a Boolean value that indicates whether the action sent by the specified object should be performed.

    Declaration

    Swift

    func webView(_ sender: WebView!, shouldPerformAction action: Selector, fromSender fromObject: AnyObject!) -> Bool

    Objective-C

    - (BOOL)webView:(WebView *)sender shouldPerformAction:(SEL)action fromSender:(id)fromObject

    Parameters

    sender

    The web view that sent the message.

    action

    The action to perform. See WebView Class Reference for information on actions a web view can perform.

    fromObject

    The object that sent the action.

    Return Value

    YEStrue if the action should be performed; otherwise, NOfalse.

    Discussion

    This method allows the delegate to control the web view’s behavior when action methods are invoked. For example, if the action is copy:, the delegate can return NOfalse to perform a copy in some other way than the default.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Returns a Boolean value that indicates whether the specified user interface item is valid.

    Declaration

    Swift

    func webView(_ sender: WebView!, validateUserInterfaceItem item: NSValidatedUserInterfaceItem!, defaultValidation defaultValidation: Bool) -> Bool

    Objective-C

    - (BOOL)webView:(WebView *)sender validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item defaultValidation:(BOOL)defaultValidation

    Parameters

    sender

    The web view that sent the message.

    item

    The user interface item being validated.

    defaultValidation

    YEStrue if the web view believes the user interface item is valid; otherwise, NOfalse.

    Return Value

    YEStrue if the specified user interface item is valid; otherwise, NOfalse.

    Discussion

    See NSUserInterfaceValidations Protocol Reference and NSValidatedUserInterfaceItem Protocol Reference for more information about user interface validation. If you do not implement this method, the value of defaultValidation is used.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Prints the contents of a web frame view.

    Declaration

    Swift

    func webView(_ sender: WebView!, printFrameView frameView: WebFrameView!)

    Objective-C

    - (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView

    Parameters

    sender

    The web view that sent the message.

    frameView

    The web frame view whose contents to print.

    Discussion

    This method is invoked when a script or a user wants to print a webpage. Typically, the delegate implements this method to prepare the web frame view content for printing. The web frame view can handle some content without intervention by the delegate. Send the documentViewShouldHandlePrint message to the web frame view to determine if it can handle printing. If this method returns YEStrue, then the delegate can print the content by sending the printDocumentView message to the web frame view. Otherwise, the delegate can use printOperationWithPrintInfo: to get an NSPrintOperation object to print the web frame view.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Returns the height of the web view’s printed page header.

    Declaration

    Swift

    func webViewHeaderHeight(_ sender: WebView!) -> Float

    Objective-C

    - (float)webViewHeaderHeight:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The height of the web view’s printed page header. Returns 0.0 if no space is reserved for the header.

    Discussion

    The height returned by this method is used to calculate the rectangle passed to the webView:drawHeaderInRect: method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Returns the height of the web view’s printed page footer.

    Declaration

    Swift

    func webViewFooterHeight(_ sender: WebView!) -> Float

    Objective-C

    - (float)webViewFooterHeight:(WebView *)sender

    Parameters

    sender

    The web view that sent the message.

    Return Value

    The height of the web view’s printed page footer. Returns 0.0 if no space is reserved for the footer.

    Discussion

    The height returned by this method is used to calculate the rectangle passed to the webView:drawFooterInRect: method.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Draws the web view’s header in the specified rectangle.

    Declaration

    Swift

    func webView(_ sender: WebView!, drawHeaderInRect rect: NSRect)

    Objective-C

    - (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect

    Parameters

    sender

    The web view that sent the message.

    rect

    The rectangle reserved for drawing the header.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Draws the web view’s footer in the specified rectangle.

    Declaration

    Swift

    func webView(_ sender: WebView!, drawFooterInRect rect: NSRect)

    Objective-C

    - (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect

    Parameters

    sender

    The web view that sent the message.

    rect

    The rectangle reserved for drawing the footer.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.4.11 and later.

  • Tags that define the types of default menu items passed to the webView:contextMenuItemsForElement:defaultMenuItems: method.

    Declaration

    Swift

    var WebMenuItemTagOpenLinkInNewWindow: Int { get } var WebMenuItemTagDownloadLinkToDisk: Int { get } var WebMenuItemTagCopyLinkToClipboard: Int { get } var WebMenuItemTagOpenImageInNewWindow: Int { get } var WebMenuItemTagDownloadImageToDisk: Int { get } var WebMenuItemTagCopyImageToClipboard: Int { get } var WebMenuItemTagOpenFrameInNewWindow: Int { get } var WebMenuItemTagCopy: Int { get } var WebMenuItemTagGoBack: Int { get } var WebMenuItemTagGoForward: Int { get } var WebMenuItemTagStop: Int { get } var WebMenuItemTagReload: Int { get } var WebMenuItemTagCut: Int { get } var WebMenuItemTagPaste: Int { get } var WebMenuItemTagSpellingGuess: Int { get } var WebMenuItemTagNoGuessesFound: Int { get } var WebMenuItemTagIgnoreSpelling: Int { get } var WebMenuItemTagLearnSpelling: Int { get } var WebMenuItemTagOther: Int { get } var WebMenuItemTagSearchInSpotlight: Int { get } var WebMenuItemTagSearchWeb: Int { get } var WebMenuItemTagLookUpInDictionary: Int { get } var WebMenuItemTagOpenWithDefaultApplication: Int { get } var WebMenuItemPDFActualSize: Int { get } var WebMenuItemPDFZoomIn: Int { get } var WebMenuItemPDFZoomOut: Int { get } var WebMenuItemPDFAutoSize: Int { get } var WebMenuItemPDFSinglePage: Int { get } var WebMenuItemPDFFacingPages: Int { get } var WebMenuItemPDFContinuous: Int { get } var WebMenuItemPDFNextPage: Int { get } var WebMenuItemPDFPreviousPage: Int { get }

    Objective-C

    enum { WebMenuItemTagOpenLinkInNewWindow = 1, WebMenuItemTagDownloadLinkToDisk, WebMenuItemTagCopyLinkToClipboard, WebMenuItemTagOpenImageInNewWindow, WebMenuItemTagDownloadImageToDisk, WebMenuItemTagCopyImageToClipboard, WebMenuItemTagOpenFrameInNewWindow, WebMenuItemTagCopy, WebMenuItemTagGoBack, WebMenuItemTagGoForward, WebMenuItemTagStop, WebMenuItemTagReload, WebMenuItemTagCut, WebMenuItemTagPaste, WebMenuItemTagSpellingGuess, WebMenuItemTagNoGuessesFound, WebMenuItemTagIgnoreSpelling, WebMenuItemTagLearnSpelling, WebMenuItemTagOther, WebMenuItemTagSearchInSpotlight, WebMenuItemTagSearchWeb, WebMenuItemTagLookUpInDictionary, WebMenuItemTagOpenWithDefaultApplication, WebMenuItemPDFActualSize, WebMenuItemPDFZoomIn, WebMenuItemPDFZoomOut, WebMenuItemPDFAutoSize, WebMenuItemPDFSinglePage, WebMenuItemPDFFacingPages, WebMenuItemPDFContinuous, WebMenuItemPDFNextPage, WebMenuItemPDFPreviousPage, };

    Constants

    • WebMenuItemTagOpenLinkInNewWindow

      WebMenuItemTagOpenLinkInNewWindow

      Open the link in a new window.

      Available in OS X v10.2 and later.

    • WebMenuItemTagDownloadLinkToDisk

      WebMenuItemTagDownloadLinkToDisk

      Download the link to a disk.

      Available in OS X v10.2 and later.

    • WebMenuItemTagCopyLinkToClipboard

      WebMenuItemTagCopyLinkToClipboard

      Copy the link to the clipboard.

      Available in OS X v10.2 and later.

    • WebMenuItemTagOpenImageInNewWindow

      WebMenuItemTagOpenImageInNewWindow

      Open the image in a new window.

      Available in OS X v10.2 and later.

    • WebMenuItemTagDownloadImageToDisk

      WebMenuItemTagDownloadImageToDisk

      Download the image to disk.

      Available in OS X v10.2 and later.

    • WebMenuItemTagCopyImageToClipboard

      WebMenuItemTagCopyImageToClipboard

      Copy the image to the clipboard.

      Available in OS X v10.2 and later.

    • WebMenuItemTagOpenFrameInNewWindow

      WebMenuItemTagOpenFrameInNewWindow

      Open the frame in a new window.

      Available in OS X v10.2 and later.

    • WebMenuItemTagCopy

      WebMenuItemTagCopy

      Copy the element to the clipboard.

      Available in OS X v10.2 and later.

    • WebMenuItemTagGoBack

      WebMenuItemTagGoBack

      Load the previous page.

      Available in OS X v10.3.9 and later.

    • WebMenuItemTagGoForward

      WebMenuItemTagGoForward

      Load the next page.

      Available in OS X v10.3.9 and later.

    • WebMenuItemTagStop

      WebMenuItemTagStop

      Stop loading the current page.

      Available in OS X v10.3.9 and later.

    • WebMenuItemTagReload

      WebMenuItemTagReload

      Reload the current page.

      Available in OS X v10.3.9 and later.

    • WebMenuItemTagCut

      WebMenuItemTagCut

      Cut the currently selected content.

      Available in OS X v10.3 and later.

    • WebMenuItemTagPaste

      WebMenuItemTagPaste

      Paste the content on the clipboard onto the current selection.

      Available in OS X v10.3 and later.

    • WebMenuItemTagSpellingGuess

      WebMenuItemTagSpellingGuess

      Suggest spellings for the misspelled word.

      Available in OS X v10.3 and later.

    • WebMenuItemTagNoGuessesFound

      WebMenuItemTagNoGuessesFound

      Indicate whether any suggested spellings for the misspelled word could be found.

      Available in OS X v10.3 and later.

    • WebMenuItemTagIgnoreSpelling

      WebMenuItemTagIgnoreSpelling

      Ignore the misspelled word.

      Available in OS X v10.3 and later.

    • WebMenuItemTagLearnSpelling

      WebMenuItemTagLearnSpelling

      Add the misspelled word to the user’s list of acceptable words.

      Available in OS X v10.3 and later.

    • WebMenuItemTagOther

      WebMenuItemTagOther

      Used when a tag for an item in the context menu can’t be determined.

      Available in OS X v10.3 and later.

    • WebMenuItemTagSearchInSpotlight

      WebMenuItemTagSearchInSpotlight

      Search SpotLight for the current selection.

      Available in OS X v10.4.11 and later.

    • WebMenuItemTagSearchWeb

      WebMenuItemTagSearchWeb

      Search the web for the current selection.

      Available in OS X v10.4.11 and later.

    • WebMenuItemTagLookUpInDictionary

      WebMenuItemTagLookUpInDictionary

      Look up the current selection in the Dictionary.

      Available in OS X v10.4.11 and later.

    • WebMenuItemTagOpenWithDefaultApplication

      WebMenuItemTagOpenWithDefaultApplication

      Open the current selection using the default application.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFActualSize

      WebMenuItemPDFActualSize

      Display a PDF document at its original size.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFZoomIn

      WebMenuItemPDFZoomIn

      Scale up a PDF document.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFZoomOut

      WebMenuItemPDFZoomOut

      Scale down a PDF document.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFAutoSize

      WebMenuItemPDFAutoSize

      Display a PDF document at a user-specified size.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFSinglePage

      WebMenuItemPDFSinglePage

      Display a PDF document one page at a time.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFFacingPages

      WebMenuItemPDFFacingPages

      Display a PDF document two pages at a time.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFContinuous

      WebMenuItemPDFContinuous

      Display all pages in a PDF document continuously, using a vertical scroll bar, if necessary.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFNextPage

      WebMenuItemPDFNextPage

      Display the next page of a PDF document.

      Available in OS X v10.4.11 and later.

    • WebMenuItemPDFPreviousPage

      WebMenuItemPDFPreviousPage

      Display the previous page of a PDF document.

      Available in OS X v10.4.11 and later.

    Discussion

    These tags define common actions a user might want to take with elements in a page. You can use the tags to differentiate between the different types of menu items.

  • Actions that the destination object of a drag operation can perform.

    Declaration

    Swift

    struct WebDragDestinationAction : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var None: WebDragDestinationAction { get } static var DHTML: WebDragDestinationAction { get } static var Edit: WebDragDestinationAction { get } static var Load: WebDragDestinationAction { get } static var Any: WebDragDestinationAction { get } }

    Objective-C

    typedef enum { WebDragDestinationActionNone = 0, WebDragDestinationActionDHTML = 1, WebDragDestinationActionEdit = 2, WebDragDestinationActionLoad = 4, WebDragDestinationActionAny = UINT_MAX } WebDragDestinationAction;

    Constants

    • None

      WebDragDestinationActionNone

      No action.

      Available in OS X v10.3 and later.

    • DHTML

      WebDragDestinationActionDHTML

      Allows DHTML (such as JavaScript) to handle the drag.

      Available in OS X v10.3 and later.

    • Edit

      WebDragDestinationActionEdit

      Allows editable documents to be changed by the drag operation.

      Available in OS X v10.3 and later.

    • Load

      WebDragDestinationActionLoad

      Allows the drag operation to change the location.

      Available in OS X v10.3 and later.

    • Any

      WebDragDestinationActionAny

      Allows any defined action to occur.

      Available in OS X v10.3 and later.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.

  • Actions that the source object of a drag operation can perform.

    Declaration

    Swift

    struct WebDragSourceAction : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var None: WebDragSourceAction { get } static var DHTML: WebDragSourceAction { get } static var Image: WebDragSourceAction { get } static var Link: WebDragSourceAction { get } static var Selection: WebDragSourceAction { get } static var Any: WebDragSourceAction { get } }

    Objective-C

    typedef enum { WebDragSourceActionNone = 0, WebDragSourceActionDHTML = 1, WebDragSourceActionImage = 2, WebDragSourceActionLink = 4, WebDragSourceActionSelection = 8, WebDragSourceActionAny = UINT_MAX } WebDragSourceAction;

    Constants

    • None

      WebDragSourceActionNone

      No action.

      Available in OS X v10.3 and later.

    • DHTML

      WebDragSourceActionDHTML

      Allows DHTML (such as JavaScript) in the source object to initiate a drag operation.

      Available in OS X v10.3 and later.

    • Image

      WebDragSourceActionImage

      Allows the user to drag an image in the source object.

      Available in OS X v10.3 and later.

    • Link

      WebDragSourceActionLink

      Allows the user to drag a link in the source object.

      Available in OS X v10.3 and later.

    • Selection

      WebDragSourceActionSelection

      Allows the user to drag a selection in the source object.

      Available in OS X v10.3 and later.

    • Any

      WebDragSourceActionAny

      Allows any defined action to occur.

      Available in OS X v10.3 and later.

    Import Statement

    Objective-C

    @import WebKit;

    Swift

    import WebKit

    Availability

    Available in OS X v10.3.9 and later.