Next Page > Hide TOC

WebEditingDelegate Protocol Reference

(informal protocol)

Framework
/System/Library/Frameworks/WebKit.framework
Availability
Available in Mac OS X v10.3.9 and later.
Companion guide
Declared in
WebEditingDelegate.h

Overview

You use a WebEditingDelegate to control or augment the editing behavior of a WebView object. Objects conforming to the WebEditingDelegate informal protocol may receive should messages before or did messages after an editing action. Typically, you implement an editing delegate if you want to change the default editing behavior.

Tasks

Controlling Editing Behavior

Responding to Notifications

Performing Commands

Getting the Undo Manager

Instance Methods

undoManagerForWebView:

Returns the undo manager to be used by a webView.

- (NSUndoManager *)undoManagerForWebView:(WebView *)webView

Availability
Declared In
WebEditingDelegate.h

webView:doCommandBySelector:

Returns whether the receiver will perform a command instead of the webView.

- (BOOL)webView:(WebView *)webView doCommandBySelector:(SEL)command

Discussion

This method returns YES if the receiver will perform command, NO otherwise. Implement this method if you want to perform command instead of letting the webView perform command.

Availability
Declared In
WebEditingDelegate.h

webView:shouldApplyStyle:toElementsInDOMRange:

Returns whether the user should be allowed to apply a style to a range of content.

- (BOOL)webView:(WebView *)webView shouldApplyStyle:(DOMCSSStyleDeclaration *)style toElementsInDOMRange:(DOMRange *)range

Discussion

This method returns YES if the user should be allowed to apply a style, specified by style, to the content, specified by range, in webView, NO otherwise.

Availability
Declared In
WebEditingDelegate.h

webView:shouldBeginEditingInDOMRange:

Returns whether the user is allowed to edit a range of content in a web view.

- (BOOL)webView:(WebView *)webView shouldBeginEditingInDOMRange:(DOMRange *)range

Discussion

This method returns YES if the user is allowed to edit webView, NO otherwise. This method is invoked when a web view attempts to become the first responder or when the user drops an object on webView. The range argument marks the section of the begin-editing request and is used to determine if editing is allowed. Typically, range is not the current selection but may becomes the current selection if this method returns YES.

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:

Returns whether the user should be allowed to change the selected range.

- (BOOL)webView:(WebView *)webView shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag

Discussion

This method returns YES if the user is allowed to change the selected range specified by the currentRange and proposedRange arguments; otherwise, NO. The selectionAffinity argument specifies the direction of the selection. The flag argument is YES if the user is still selecting, NO otherwise.

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldChangeTypingStyle:toStyle:

Returns whether the user should be allowed to change the typing style in a web view.

- (BOOL)webView:(WebView *)webView shouldChangeTypingStyle:(DOMCSSStyleDeclaration *)currentStyle toStyle:(DOMCSSStyleDeclaration *)proposedStyle

Discussion

This method returns YES if the user should be allowed to change the typing style in webView to proposedStyle, NO otherwise. The currentStyle argument is the old style. You can implement this method to take some other action—for example, set the typing style to a different style—and return NO .

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldDeleteDOMRange:

Returns whether the user should be allowed to delete a range of content.

- (BOOL)webView:(WebView *)webView shouldDeleteDOMRange:(DOMRange *)range

Discussion

This method should returns YES if the user should be allowed to delete the content specified by range, NO otherwise. This method may perform an alternate action—for example, delete a different range—and return NO.

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldEndEditingInDOMRange:

Returns whether the user should be allowed to end editing.

- (BOOL)webView:(WebView *)webView shouldEndEditingInDOMRange:(DOMRange *)range

Discussion

This method returns YES if the user should be allowed to end editing webView, NO otherwise. This method is invoked when a web view attempts to resign as the first responder. Typically, the range argument designates the current selection, although it might not. Use the range argument to help determine if the user can end editing. If this method returnsYES, webView will end editing and resign as the first responder.

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldInsertNode:replacingDOMRange:givenAction:

Returns whether the user should be allowed to insert a node in place of a range of content.

- (BOOL)webView:(WebView *)webView shouldInsertNode:(DOMNode *)node replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action

Discussion

This method returns YES if the user should be allowed to insert node in webView, NO otherwise. The range argument is the portion of the content that will be replaced with node. The action argument indicates the type of user action that initiated the insertion. This method may perform an alternate action—for example, insert a different node—and return NO.

Availability
See Also
Declared In
WebEditingDelegate.h

webView:shouldInsertText:replacingDOMRange:givenAction:

Returns whether a user should be allowed to insert text in place of a range of content.

- (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action

Discussion

This method returns YES if the user should be allowed to insert text in webView, NO otherwise. This method is invoked when one of the replaceSelectionWith... messages is sent to a webView. The range argument is the portiion of the document that will be replaced with text. The action argument indicates the type of user action that initiated the insertion. This method may perform an alternate action—for example, insert different text—and return NO.

Availability
See Also
Declared In
WebEditingDelegate.h

webViewDidBeginEditing:

Sent by the default notification center when the user begins editing the web view.

- (void)webViewDidBeginEditing:(NSNotification *)notification

Discussion

The notification argument is always WebViewDidBeginEditingNotification. You can retrieve the WebView object by sending object to notification.

Availability
See Also
Declared In
WebEditingDelegate.h

webViewDidChange:

Sent by the default notification center when the user changes content in the web view.

- (void)webViewDidChange:(NSNotification *)notification

Discussion

The notification argument is always WebViewDidChangeNotification. You can retrieve the WebView object by sending object to notification.

Availability
See Also
Declared In
WebEditingDelegate.h

webViewDidChangeSelection:

Sent by the default notification center when the user changes the selection in the web view.

- (void)webViewDidChangeSelection:(NSNotification *)notification

Discussion

The notification argument is always WebViewDidChangeSelectionNotification. You can retrieve the WebView object by sending object to notification.

Availability
See Also
Declared In
WebEditingDelegate.h

webViewDidChangeTypingStyle:

Sent by the default notification center when the user changes the typing style in the web view.

- (void)webViewDidChangeTypingStyle:(NSNotification *)notification

Discussion

The notification argument is always WebViewDidChangeTypingStyleNotification. You can retrieve the WebView object by sending object to notification.

Availability
See Also
Declared In
WebEditingDelegate.h

webViewDidEndEditing:

Sent by the default notification center when the user stops editing the web view.

- (void)webViewDidEndEditing:(NSNotification *)notification

Discussion

The notification argument is always WebViewDidEndEditingNotification. You can retrieve the WebView object by sending object to notification.

Availability
See Also
Declared In
WebEditingDelegate.h

Constants

WebViewInsertAction

Indicate the type of user action that initiated a delegate message.

typedef enum {
   WebViewInsertActionTyped,
   WebViewInsertActionPasted,
   WebViewInsertActionDropped,
} WebViewInsertAction;

Constants
WebViewInsertActionTyped

Indicates the user inserted content by typing.

Available in Mac OS X v10.3 and later.

Declared in WebEditingDelegate.h.

WebViewInsertActionPasted

Indicates the user inserted content by pasting.

Available in Mac OS X v10.3 and later.

Declared in WebEditingDelegate.h.

WebViewInsertActionDropped

Indicates the user inserted content by dropping.

Available in Mac OS X v10.3 and later.

Declared in WebEditingDelegate.h.

Discussion

These constants are described in WebEditingDelegate.

Availability


Next Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-04-08)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.