Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Cocoa SWT GLCanvas Event Handling Problems

Scott,

We are targeting 1.6, thus I haven't tested the 32-bit build.

The snippet I pasted below was an excerpt straight from SWT/Cocoa's GLCanvas.java (3.5/M5). I'm not attempting to do any NS* operations from app code. We're using GLCanvas (for all platforms) in conjunction with JOGL and its DrawableFactory.createExternalContext(), exactly as in Snippet209.

Took Snippet209 and added a mouse listener (see below) - I'm not getting any mouse events (but I'm getting them on my Linux box).

I agree with you regarding SWT doesnt knowing NSOpenGLView is a Widget subclass, and I think this is exactly the problem in SWT/Cocoa's GLCanvas: It creates a NSOpenGLView, that one receives all the mouse events (from Cocoa's perspective), but they are not forwarded to the SWT Canvas itself.

/Stefan

BTW: Our tests regarding the transition to Cocoa on the Mac have so far been extremely positive. Big thanks to everyone involved in the Cocoa SWT port!

--
Stefan Müller Arisona
Software Architect, Procedural Inc.

On Mar 3, 2009, at 6:35 PM, Scott Kovatch wrote:

Stefan,

Have you tried the 32-bit build? Or are you targeting 1.6?

Someone else here can correct me, but I¹m pretty sure you don¹t want to create an NSOpenGLView directly. The SWT doesn¹t know it¹s a Widget subclass so it won¹t receive SWT events. Instead you would use JOGL or a related
technology and wrap the GLCanvas around that. See this snippet:
<http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/e
clipse/swt/snippets/Snippet209.java?view=co>  This is how I tested the
OpenGL support.

-- Scott

On 3/3/09 3:12 AM, "Stefan Müller Arisona" <sma@xxxxxxxxxxxxxx> wrote:

As we are on the way to prepare our applications for Eclipse 3.5, we've tried out the Cocoa 64bit builds. As it seems, there is a problem with event handling of GLCanvas: When registering Mouse Listeners to the Canvas, mouse events are not received. The problem seems to be around here (Constructor of
GLCanvas.java):

glView = (NSOpenGLView)new NSOpenGLView().alloc();
if (glView == null) {
dispose ();
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
}
glView.initWithFrame(parent.view.bounds(), pixelFormat);
glView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
parent.view.addSubview(glView);



Since the glView is added to the parent's view, mouse event still go to the view of GLCanvas (I guess...). I've been able to receive mouse events, when i
change the last line to:

view.addSubview(glView)

But then autoresizing isnt working, and I havent been able to find a solution
for this so far.


---------------
Scott Kovatch
Flex Engineering
Adobe Systems, Inc.
skovatch@xxxxxxxxx

I am Scott Kovatch, and I approved this message.

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

Attachment: Snippet209.java.zip
Description: Zip archive



Back to the top