WebEditingDelegate Protocol Reference
(informal protocol)
| Framework | /System/Library/Frameworks/WebKit.framework |
| Availability | Available in OS X v10.3.9 and later. |
| Companion guide | |
| Declared in | WebEditingDelegate.h |
Overview
You use 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
-
– webView:shouldApplyStyle:toElementsInDOMRange: -
– webView:shouldBeginEditingInDOMRange: -
– webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting: -
– webView:shouldChangeTypingStyle:toStyle: -
– webView:shouldDeleteDOMRange: -
– webView:shouldEndEditingInDOMRange: -
– webView:shouldInsertNode:replacingDOMRange:givenAction: -
– webView:shouldInsertText:replacingDOMRange:givenAction:
Responding to Notifications
-
– webViewDidBeginEditing: -
– webViewDidChange: -
– webViewDidChangeSelection: -
– webViewDidChangeTypingStyle: -
– webViewDidEndEditing:
Performing Commands
Getting the Undo Manager
Instance Methods
undoManagerForWebView:
Returns the undo manager to be used by a web view.
Parameters
- webView
The web view that the user is editing.
Return Value
The undo manager.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:doCommandBySelector:
Returns whether the receiver performs a command instead of the web view.
Parameters
- webView
The web view that the user is editing.
- command
The command to perform.
Return Value
YES if the receiver will perform command; otherwise, NO.
Discussion
Implement this method if you want to perform command instead of letting the web view perform command.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:shouldApplyStyle:toElementsInDOMRange:
Returns whether the user should be allowed to apply a style to a range of content.
Parameters
- webView
The web view that the user is editing.
- style
The style to apply.
- range
The range of the content.
Return Value
YES if the user should be allowed to apply the style to the content range; otherwise, NO.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:shouldBeginEditingInDOMRange:
Returns whether the user is allowed to edit a range of content in a web view.
Parameters
- webView
The web view that the user is editing.
- range
The section of the begin-editing request; 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.
Return Value
YES if the user is allowed to edit webView; otherwise, NO.
Discussion
This method is invoked when a web view attempts to become the first responder or when the user drops an object on it.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:
Returns whether the user should be allowed to change the selected range.
Parameters
- webView
The web view that the user is editing.
- currentRange
The old range the user wants to change.
- proposedRange
The new range the user wants to select.
- selectionAffinity
The direction of the selection.
- flag
YESif the user is still selecting; otherwise,NO.
Return Value
YES if the user is allowed to change the selected range; otherwise, NO.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebEditingDelegate.hwebView:shouldChangeTypingStyle:toStyle:
Returns whether the user should be allowed to change the typing style in a web view.
Parameters
- webView
The web view that the user is editing.
- currentStyle
The old style the user wants to change.
- proposedStyle
The new style the user wants to set.
Return Value
YES if the user should be allowed to change the typing style in webView to proposedStyle; otherwise, NO.
Discussion
You can implement this method to take some other action—for example, set the typing style to a different style—and return NO .
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebEditingDelegate.hwebView:shouldDeleteDOMRange:
Returns whether the user should be allowed to delete a range of content.
Parameters
- webView
The web view that the user is editing.
- range
The range of the content to delete.
Return Value
YES if the user should be allowed to delete the content specified by range; otherwise, NO.
Discussion
This method may perform an alternate action—for example, delete a different range—and return NO.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebEditingDelegate.hwebView:shouldEndEditingInDOMRange:
Returns whether the user should be allowed to end editing.
Parameters
- webView
The web view that the user is editing.
- range
Typically, the current selection, although it might not be. Use the range parameter to help determine whether the user can end editing.
Return Value
YES if the user should be allowed to end editing webView; otherwise, NO. If this method returnsYES, webView ends editing and resigns as the first responder.
Discussion
This method is invoked when a web view attempts to resign as the first responder.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:shouldInsertNode:replacingDOMRange:givenAction:
Returns whether the user should be allowed to insert a node in place of a range of content.
Parameters
- webView
The web view that the user is editing.
- node
The content to insert.
- range
The portion of the content that is replaced with node.
- action
Indicates the type of user action that initiated the insertion.
Return Value
YES if the user should be allowed to insert node in webView; otherwise, NO.
Discussion
This method may perform an alternate action—for example, insert a different node—and return NO.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebView:shouldInsertText:replacingDOMRange:givenAction:
Returns whether a user should be allowed to insert text in place of a range of content.
Parameters
- webView
The web view that the user is editing.
- text
The text to insert.
- range
The portion of the document that will be replaced with text.
- action
Indicates the type of user action that initiated the insertion.
Return Value
YES if the user should be allowed to insert text in webView; otherwise, NO.
Discussion
This method may perform an alternate action—for example, insert different text—and return NO.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebViewDidBeginEditing:
Sent by the default notification center when the user begins editing the web view.
Parameters
- notification
Always set to
WebViewDidBeginEditingNotification. You can retrieve theWebViewobject by sendingobjectto notification.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebViewDidChange:
Sent by the default notification center when the user changes content in the web view.
Parameters
- notification
Always set to
WebViewDidChangeNotification. You can retrieve theWebViewobject by sendingobjectto notification.
Availability
- Available in OS X v10.3.9 and later.
See Also
Declared In
WebEditingDelegate.hwebViewDidChangeSelection:
Sent by the default notification center when the user changes the selection in the web view.
Parameters
- notification
Always set to
WebViewDidChangeSelectionNotification. You can retrieve theWebViewobject by sendingobjectto notification.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebViewDidChangeTypingStyle:
Sent by the default notification center when the user changes the typing style in the web view.
Parameters
- notification
Always set to
WebViewDidChangeTypingStyleNotification. You can retrieve theWebViewobject by sendingobjectto notification.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hwebViewDidEndEditing:
Sent by the default notification center when the user stops editing the web view.
Parameters
- notification
Always set to
WebViewDidEndEditingNotification. You can retrieve theWebViewobject by sendingobjectto notification.
Availability
- Available in OS X v10.3.9 and later.
Declared In
WebEditingDelegate.hConstants
WebViewInsertAction
The type of user action that initiated a delegate message.
typedef enum {
WebViewInsertActionTyped,
WebViewInsertActionPasted,
WebViewInsertActionDropped,
} WebViewInsertAction;
Constants
WebViewInsertActionTypedIndicates the user inserted content by typing.
Available in OS X v10.3 and later.
Declared in
WebEditingDelegate.h.WebViewInsertActionPastedIndicates the user inserted content by pasting.
Available in OS X v10.3 and later.
Declared in
WebEditingDelegate.h.WebViewInsertActionDroppedIndicates the user inserted content by dropping.
Available in OS X v10.3 and later.
Declared in
WebEditingDelegate.h.
Discussion
These constants are described in WebEditingDelegate.
Availability
- Available in OS X v10.3.9 and later.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-02-24)