0

OK, here's the situation. I have:

  • A Webview
  • Lots of NSTextFields
  • Other unrelated controls

Normally, the Edit > Undo menu item links to First Responder's undo: action. And everything works fine + you can even "undo" while typing in an NSTextField.

Now, what if I want to handle this "undo" action, in a different way, only for my WebView.

I've been thinking of two approaches:

  • Link the "Undo" item to a custom action and check who is the First Responder. If it's the Webview, then do what needs to be done. Else, "pass" the event to the control. (However, when attempting a [FIRST_RESPONDER performSelector:@selector(undo:)], first it doesn't seem to recognize the selector and last but not least nothing happens.)

  • Link the "Undo" to the first responder's undo:(as usual), subclass the Webview and add a custom - (void)undo:(id)sender action. In that case though, when the webview is active, the "Undo" item is grayed-out, so I can't do anything whatsoever, not even check whether the custom method would be called.


Suggestions? How would you go about that?

What am I missing?

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223

1 Answers1

0

I think this is the answer: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Protocols/WebEditingDelegate_Protocol/

Also reference this: Removing undo actions for a WebView's NSUndoManager

Community
  • 1
  • 1
Tyler Liu
  • 19,552
  • 11
  • 100
  • 84