Not receiving mouseDown/Up events in borderless window . . .
Not receiving mouseDown/Up events in borderless window . . .
- Subject: Not receiving mouseDown/Up events in borderless window . . .
- From: "Michael A. Crawford" <email@hidden>
- Date: Sat, 12 Sep 2009 22:12:09 -0400
I have created a borderless window that is used to display a custom
graphic, which need to respond to the enter key or a mouse click by
closing itself. Seems straightforward enough. It works great on Snow
Leopard (10.6) but I do not get the mouse events on Leopard (10.5).
Hitting the enter key works on both.
Anyone seen this behavior before? I've included the code so you could
see if I've left something out.
#import <Carbon/Carbon.h>
#import "CDExportCompleteWindow.h"
@implementation CDExportCompleteWindow
// We override this method simply for the sake of making the window
borderless
// with a clear background.
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)windowStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)deferCreation
{
windowStyle = NSBorderlessWindowMask;
self = [super initWithContentRect:contentRect
styleMask:windowStyle
backing:bufferingType
defer:deferCreation];
if ( self )
{
[self setLevel:NSFloatingWindowLevel];
[self center];
[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
}
return self;
}
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (void)keyDown:(NSEvent*)event
{
MCLog(@"keyDown:%@", event);
if ( kVK_Return == event.keyCode )
{
[self close];
}
}
- (void)mouseUp:(NSEvent*)event
{
MCLog(@"mouseUp:%@", event);
if ( NSPointInRect(event.locationInWindow, NSMakeRect(411, 3, 81,
29)) )
{
[self close];
}
}
@end
-Michael
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden