Mouse up events in NSImageViews
Mouse up events in NSImageViews
- Subject: Mouse up events in NSImageViews
- From: Matthew Smith <email@hidden>
- Date: Fri, 15 Nov 2002 10:10:40 +1100
Hello,
I'm having trouble getting "mouse up" events when I click on an NSImageView
in a window... Is this some known bug?
All the other mouse events come though fine...
Any other ideas on why this is happening?
Cheers
Matt
A project showing an example of this is at
http://www.ids.org.au/~mps/test.tgz
or see the code below:
// main.mm
#import <Cocoa/Cocoa.h>
@interface AppController : NSApplication{} @end
@implementation AppController
-(void)finishLaunching
{
[super finishLaunching];
NSWindow * myWindow = [[NSWindow alloc] initWithContentRect:
NSMakeRect(100, 200, 400, 400)
styleMask: NSTitledWindowMask
backing: NSBackingStoreBuffered
defer: FALSE];
[myWindow setTitle: @"Test Window"];
NSRect imageRect = [[myWindow contentView] bounds];
NSImageView * imageView = [[NSImageView alloc] initWithFrame:
imageRect];
[imageView setImage: [[NSImage alloc] initWithSize: imageRect.size]];
[[myWindow contentView] addSubview: imageView];
[myWindow makeKeyAndOrderFront: self];
}
- (void) sendEvent:(NSEvent *)theEvent
{
switch ([theEvent type])
{
case NSLeftMouseDown:
printf("l mouse down\n");
[super sendEvent: theEvent];
break;
case NSLeftMouseUp:
printf("l mouse up\n");
[super sendEvent: theEvent];
break;
case NSRightMouseDown:
printf("r mouse down\n");
[super sendEvent: theEvent];
break;
case NSRightMouseUp:
printf("r mouse up\n");
[super sendEvent: theEvent];
break;
default:
[super sendEvent: theEvent];
break;
}
}
@end
int main(int argc, const char *argv[])
{
NSApp = [AppController sharedApplication];
[NSApp run];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.