[racket-dev] Windowing API

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Sat Oct 15 11:18:07 EDT 2011

Thanks that worked.

-Eric

On Oct 15, 2011, at 7:07 AM, Matthew Flatt wrote:

> I think you'll have to handle `on-size' at the `racket/gui' level:
> 
> (define panel
>   (new (class panel%
>          (define/override (on-size w h)
>            (tellv web-view setFrame:
>                   #:type _NSRect (make-NSRect (make-NSPoint 0 0) 
>                                               (make-NSSize w h))))
>          (super-new))
>        [parent frame]))
> 
> ;; instead of `frame-view':
> (define panel-view (send panel get-client-handle)) 
> (tellv panel-view addSubview: web-view)
> 
> 
> At Fri, 14 Oct 2011 23:19:32 -0700, Eric Dobson wrote:
>> I am trying to implement a WebKit panel in Racket, and am running in to some 
>> trouble with the windowing API. I cannot get resizing to work. In OS X it 
>> looks like it is supposed to be enabled by default so I assume racket is 
>> changing it so that it can do its layout algorithm. The problem is that If I 
>> want to hook into this It looks like I need to get access to the platform 
>> specific racket windowing API. Currently I can get access to the Objective C 
>> layer, but not to the hidden racket layer. Maybe this is not the way I should 
>> approach this but I'm hoping someone can help.
>> 
>> 
>> 
>> #lang racket 
>> (require racket/gui/base ffi/unsafe/objc ffi/unsafe) 
>> (require mred/private/wx/cocoa/types 
>>         (prefix-in c: mred/private/wx/cocoa/window)) 
>> (define webkit-lib (ffi-lib (format 
>> "/System/Library/Frameworks/WebKit.framework/WebKit"))) 
>> 
>> (import-class WebView) 
>> (import-class NSURLRequest) 
>> (import-class NSURL) 
>> (define web-view (tell (tell WebView alloc) initWithFrame: #:type _NSRect 
>> (make-NSRect (make-NSPoint 0 0) (make-NSSize 300 300)) frameName: #f 
>> groupName: #f)) 
>> (define frame (new frame% (label "test-frame") (width 300) (height 300))) 
>> ;(define racket-web-view (new c:window% (parent frame) (cocoa web-view) 
>> (no-show? #f))) 
>> ;This problem is here the parent argument needs to be the platform specific 
>> window and not the generic one
>> (define frame-view (send frame get-client-handle)) 
>> (tellv frame-view addSubview: web-view) 
>> 
>> (define request (tell NSURLRequest requestWithURL: (tell NSURL URLWithString: 
>> #:type _NSString "http://www.google.com"))) 
>> (tellv (tell web-view mainFrame) loadRequest: request) 
>> 
>> (send frame show #t) 
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/dev




Posted on the dev mailing list.