• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Mouse up events in NSImageViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mouse up events in NSImageViews


  • Subject: Mouse up events in NSImageViews
  • From: Matthew Smith <email@hidden>
  • Date: Thu, 14 Nov 2002 16:26:14 +1100

Hello - sorry about the cross-post,

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.

  • Prev by Date: Testing...
  • Next by Date: Re: cocoa-dev digest, Vol 2 #1506 - 16 msgs
  • Previous by thread: Testing...
  • Next by thread: Mouse up events in NSImageViews
  • Index(es):
    • Date
    • Thread