problem with sheet contextInfo
problem with sheet contextInfo
- Subject: problem with sheet contextInfo
- From: Jim Balhoff <email@hidden>
- Date: Tue, 26 Feb 2002 08:55:22 -0500
Hello everyone,
I have a question about the way contextInfo works when running a
sheet. I am learning to program as I learn Cocoa, so if I'm missing
something completely basic, just let me know. I have a window with an
NSForm with two cells. When a cell sends its action, it triggers a
method that starts a sheet. This method sends the sender (an
NSFormCell) as the contextInfo. I confirm the identity of the sender by
first printing its objectValue to the console. When the sheet ends (by
pressing a button), I use the contextInfo to tell the cell that started
the sheet to clear itself. The problem is, if I finished the editing of
cell 1 (which sends the action) by clicking into cell 2, it is cell 2
that is cleared. I would have expected cell 1, which I passed as the
contextInfo, to be cleared.
Thanks in advance! - some code describing the situation follows.
-Jim
/* AppController */
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject
{
IBOutlet NSForm *myForm;
IBOutlet NSWindow *mySheet;
}
- (IBAction)cellCompletedEdit:(id)sender;
- (IBAction)endMySheet:(id)sender;
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(NSFormCell *)contextInfo;
@end
**************************************************************************
**
#import "AppController.h"
@implementation AppController
- (IBAction)cellCompletedEdit:(id)sender
{
NSLog(@"Value in sender cell is: %@", [sender objectValue]);
[NSApp beginSheet:mySheet modalForWindow:[myForm window]
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:sender];
}
- (IBAction)endMySheet:(id)sender
{
[mySheet orderOut:sender];
[NSApp endSheet:mySheet returnCode:1];
}
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(NSFormCell *)contextInfo
{
[contextInfo setObjectValue:nil];
}
@end
_______________________________________________
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.