Re: using Cocoa WebView with LispWorks 5 for OS X.
Bill,
Thanks, that's the start I needed. I'm very close now (I
think). Loading the WebKit framework and changing the message to go
to the mainFrame gets me past any LispWorks errors, but it's still
not displaying any web pages.
This is what I have now:
(objc:ensure-objc-initialized
:modules
'("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
"/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
"/System/Library/Frameworks/WebKit.framework/Versions/A/WebKit"))
(defun get-web-view (url)
(let ((web-view (make-instance 'capi:cocoa-view-pane :view-class "WebView"))
(request (objc:invoke "NSURLRequest" "requestWithURL:"
(objc:invoke "NSURL" "URLWithString:"
url))))
(capi:contain web-view)
(objc:invoke (objc:invoke (capi:cocoa-view-pane-view web-view)
"mainFrame") "loadRequest:" request)
web-view)
Calling (get-web-view "http://www.google.com") puts up the CAPI
window and there are no errors in the process, but nothing shows in the pane.
I'm not sure if this is because of a CAPI problem/limitation or if I
need to do something else on the Cocoa side.
Any guidance welcome,
Chris
At 10:10 AM 12/19/2006, Bill Atkins wrote:
>On 12/19/06, Chris Perkins <cperkins@medialab.com> wrote:
>>
>>Does anyone have an example (or advice) for using WebKit? Ideally,
>>within a CAPI window.
>>
>>I'm not yet familiar as I should be with CAPI, and I've never
>>programmed a line of Cocoa in my life. Though what I'm trying to do
>>seems like it shouldn't be hard. I just want to open a browser
>>window within my UI and have it load a particular URL.
>>
>>This page of the Apple developer documentation shows the basic Cocoa
>>code for making a WebView component load a
>>URL:
>>http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/SimpleBrowsing.html#//apple_ref/doc/uid/20002025-CJBEHAA
>>
>>That seems like it should be relatively direct to translate to the
>>LispWorks Objective-C FLI, but the part that is most confounding me
>>now is how to instantiate and size the WebView object in the first
>>place, and what to do with it, vis-a-vis CAPI, once I have it. The
>>Apple documentation seems to always assume one is using Interface
>>Builder, which we are not (though if there is a LispWorks-to-IB
>>bridge, someone let me know).
>>
>>Thanks for any help,
>>
>>Chris Perkins
>>Media Lab, Inc.
>
>It should be something like the following:
>
>(let ((web-view (make-instance 'capi:cocoa-view-pane :view-class "WebView"))
> (request (objc:invoke "NSURLRequest" "requestWithURL:"
> (objc:invoke "NSURL" "URLWithString:"
>"http://www.google.com"))))
> (capi:contain web-view)
> (objc:invoke (capi:cocoa-view-pane-view web-view) "loadRequest:" request)
> web-view)
>
>The code doesn't work because it can't find the WebView class. Maybe
>someone else can help with that, but this is at least the right
>direction.
>
>--
>Bill Atkins