Eli Blokh
Eli Blokh

Reputation: 12293

events don't invoke in cocoa application

Here's a header file:

@interface MainDreamer : NSWindow <NSWindowDelegate>
{    
    IBOutlet NSTextField *myField;
    IBOutlet NSTableView *myTable;    
    IBOutlet NSImageView *myView;

    IBOutlet NSMutableArray *mylist;  
    IBOutlet NSMutableArray *dataset;
}

- (IBAction)addRecord:(id)sender;
- (IBAction)deleterecord:(id)sender;

@property (assign) IBOutlet NSWindow *window;

@end

I implemented several events in .m file:

- (void) mouseDown:(NSEvent *)theEvent{
    NSLog(@"mouse down");
}

- (void) mouseUp:(NSEvent *)theEvent{
    NSLog(@"mouse up");
}

- (void) tableViewSelectionDidChange: (NSNotification *) notification{
    NSLog(@"selected row changed");
}

- (BOOL) acceptsFirstResponder{
    return YES;
}

However neither of them are invoked (I checked it by putting in a breakpoint).

Other methods in the program work fine including, so everything with wires seems to be OK.

Why don't the events handlers launch?

Upvotes: 0

Views: 131

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89569

If you go to your xib file and click on your window, what is the "Custom Class" type set to? NSWindow or MainDreamer.

The fact it's not hitting any of your methods tells me it's still set to NSWindow. Try setting your "Custom Class" to MainDreamer and see what happens then.

Upvotes: 1

Related Questions