Hi all,
So I have a view (SphereView) in which I have OpenGL rendering taking place, and if I create the containing window for the view using:
var mask = CPBorderlessBridgeWindowMask;
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:mask];
var contentView = [theWindow contentView];
[contentView setBackgroundColor:[CPColor colorWithHexString:@"EEEEEE"]];
// Create GL View
_view = [[SphereView alloc] initWithFrame:[contentView bounds]];
[_view setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[_view setCenter:[contentView center]];
[contentView addSubview:_view];
... then all goes well. I can zoom in, out and around using the W, A, S, D keys. If, however, I change the window mask to be
var mask = CPClosableWindowMask;
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,1024,768)
... then my key processing disappears. Sphereview.j has
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (void)keyDown:(CPEvent)theEvent
{
switch ([theEvent keyCode]) {
case 119: _keyZ = 0.1; break; // w
case 115: _keyZ = -0.1; break; // s
case 100: _keyX = -0.1; break; // d
case 97 : _keyX = 0.1; break; // a
}
}
And it's unchanged between the two window-styles. Is there anything else I ought to be doing in the window mask to indicate that I really do want key-event processing ? Or is it just understood that only some types of window have key processing ?
One other thing - the OpenGL window base class defines its own canvas element and then obtains the Open-GL context from it, using:
/******************************************************************************\
\******************************************************************************/
- (id)initWithFrame:(CGRect)aFrame
self = [super initWithFrame:aFrame];
_DOMCanvasElement = document.createElement("canvas");
_DOMCanvasElement.width = CGRectGetWidth([self bounds]);
_DOMCanvasElement.height = CGRectGetHeight([self bounds]);
_DOMCanvasElement.style.top = "0px";
_DOMCanvasElement.style.left = "0px";
_DOMElement.appendChild(_DOMCanvasElement);
_gl = [[GLContext alloc] initWithGL:[self _context]];
/******************************************************************************\
\******************************************************************************/
gl = _DOMCanvasElement.getContext("webkit-3d");
gl = _DOMCanvasElement.getContext("moz-webgl");
CPLog.error(@"Could not create context")
... so perhaps there's more plumbing that I'd need to do to get events to transport across in the non-full-screen-window case ?
Cheers
Simon