A General/WebView is part of General/WebKit, similar to a browser view in Safari - allows an app to display a web page (obviously). You can even allow the General/WebView to edit HTML pages by setting its editable flag to YES. For a quick tutorial, check out: http://www.cocoadevcentral.com/articles/000077.php
For retrieving the HTML content of a web view, see General/GettingHTMLSourceInWebView. http://goo.gl/General/OeSCu
I’m having some problems with General/WebView in edit mode. It’s just acting messed up and buggy in general. I read that Apple uses an editable General/WebView for Mail.app (probably to get the pretty quoting effects easily). The editor acts perfectly fine in Mail. The problems I’m having are below.
Bulleted lists are a joy … If the source is as follows:
I want to subclass General/NSScroller and use it in a General/WebView, so I can change the look of the scrollbars (at very least the size). I know General/WebViews? usually have lots of frames, but I’m injecting the HTML, so I have control over that. I can get the General/NSScroller and General/NSScrollView objects just fine, but I can’t figure out what to to from there. “- (void)setVerticalScroller:(General/NSScroller *)aScroller” doesn’t seem to work. I’ve subclassed with Interface Builder before just fine, but I can’t seem to understand how to do it programmably. This is about all I could find: http://lists.apple.com/archives/webkitsdk-dev/2003/Dec/msg00004.html. … and you place the cursor before the ‘T’ in Two and press return, a blank line is created. So far, so good. However, try clicking onto that blank line and inserting text. Not possible. If you type something before the T, press return to separate it, place your cursor before the newly-inserted text and press delete, all is well again. Strange behavior.
General/DOMCore outright mangles your markup. All the whitespace is screwed up (even on items you haven’t edited) and the tags are all upper-case. (TBODY comment removed from previous post because I stupidly did not realize it’s part of HTML4.0 … duh).
Unexpected Loss Of Data
I haven’t been able to reliably reproduce this, but occasionally, when you select text and type to replace it, the entire content of the document is replaced.
Can anybody offer any insight on taming this (potentially powerful) beast?
Update - According to an Apple developer, the list and table editing issues are problems they’re working to resolve. The data loss issue has been heard of but they need bug reports. If you’ve experienced this, please provide information to Apple via General/RadarWeb.
I’m having difficulty catching spaces in my General/WebView subclass. keyDown: simply does not respond to space for some reason. Surprisingly enough, when a window contains a webview, it also does not catch space. It catches everything else just fine (such as ‘m’,’c’,etc.).
For your first question, this is probably because the General/WebView hierarchy already catches spaces. (If you press space, it scrolls down the page.) It doesn’t catch the others. If you’re overriding keyDown:, then the first responder is eating the space events before you can handle them. If you really need to handle spaces differently, you’ll probably have to override sendEvent: in your window.
I continued my tests with General/WebView, and this I think pretty much exemplifies the problem. If I have a normal General/NSView subclass and write keyDown, after making the subclass first responder, space bar events are caught. However, interestingly enough, as soon as I insert a General/WebView as a subview of this General/NSView, it stops catching spaces. Why is this?
Because the General/WebView (or a subview of it) is becoming first responder, not your General/NSView subclass.
That explains something I’ve been wondering about for a while. You know how you can have QT media open in your Safari (or other browser) window? Quicktime shortcuts (like space for play and pause) control the player as usual, but Safari key actions (like using delete to go back a page) do not work at all. Evidently (because of the first responder change), this applies to any Cocoa app with subviews…anywhere!
The responder chain seems to be simultaneously one of the most important things in a Cocoa app, and one of the things that Cocoa programmers know least about. If you aren’t already intimately familiar with how it works, do yourself a favor and read all of Apple’s conceptual documentation surrounding General/NSResponder.
Did you get this, the missing webview solved? I got the same issue. Thanks
bool val = NO; // this value is to enable/disable scrollbars General/webView windowScriptObject]evaluateWebScript:[[[NSString stringWithFormat:@”document.body.style.overflow=’%@’;”,val?@”visible”:@”hidden”]];