[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [platform-swt-dev] Reparenting a Cocoa App. on Mac OS/X?
- From: Scott Kovatch <skovatch.swt@xxxxxxxxx>
- Date: Mon, 17 Jan 2011 08:28:41 -0800
- Delivered-to: email@example.com
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:content-type:mime-version:subject:from :in-reply-to:date:content-transfer-encoding:message-id:references:to :x-mailer; bh=G6HLQx1pEYBLvJndAg1ZUo3yzSLxzyUYahWm/Wbjcro=; b=WTWT8HsSiV8pYuICmRS0tmRJ/Mg46Uq4KchVClF6SkwmW+RHGpjEjNSM3zOtebWUOV jblhLaVqoDUiOgtTIrDjIVvflg32qCoq1lKblyt/KdHMP+/d2YmnOKeqq7o0MckKV/N4 pi4M06idYPENDNmhPHTP3vYnQR5r1jDr5yOPs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=v3KWNBjRZ72GWnaqJiry+V6bCPpGCDfEPmgJaOcuSh6JNZZ90ymC8OPowT68JepeA7 dvbG5ftWd1MznnjgpPZ8Ih2osV52Y+i9LYFaWlI+ccjqKgM6cF1yWbSE5Ov+NAaOPEfn 4a+88zczAAsV9htv9ISU47J5g8PgAitpm5vuI=
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.. ?
> platform-swt-dev mailing list