• 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
problem with sheet contextInfo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: problem with sheet contextInfo
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: text-to-speech problems, or is it just me?
  • Next by Date: Re: text-to-speech problems, or is it just me?
  • Previous by thread: Re: Putting Non Date in Date formatted text field
  • Next by thread: Re: problem with sheet contextInfo
  • Index(es):
    • Date
    • Thread