[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Reparenting a Cocoa App. on Mac OS/X?

Andrew,

The Cocoa port doesn't use HIViewRef, as that's the Carbon way of doing it. On Cocoa you want NSView.

For 3.7 take a look at org.eclipse.swt/Eclipse\ SWT\ WebKit/cocoa/org/eclipse/swt/browser/WebKit.java, which embeds a WebView into an SWT Composite. Lines 202 - 214 are the pattern you want to follow for your needs.

First, the Cocoa NSView subclass is created and initialized. Next, the autoresizing mask is set so that the new view always matches the height and width of the parent view. Finally, the call to display.setData() associates the SWT control with the NSView so that native events get forwarded to the SWT object.

The Listener subclass in lines 216-267 also needed so that when the user clicks on your view focus goes directly to the custom view you created, and so that you can clean up the custom view when the parent SWT object is disposed.

WebKit has pretty much everything you need. Please post any followup questions to the main SWT group and we'll be able to help out there.

-- Scott K.

On Jan 16, 2011, at 5:01 PM, Andrew Sealy-Bell wrote:

> Hi all,
> 
> Does anybody have an example of reparenting a native OSX app. in SWT? i've managed to get it working on Windows but not on OSX so far.  It's kind of urgent (isn't everything!) so i'd appreciate any help or pointers.  I looked at the Safari class as that seems to do it but I don't have access to the methods required in the OS class.
> 
> I'm sure somebody has done this before.. ?
> 
> Regards,
> 
> Andrew.
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev