• 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
NSTableViewSelectionDidChangeNotification not posted on time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableViewSelectionDidChangeNotification not posted on time


  • Subject: NSTableViewSelectionDidChangeNotification not posted on time
  • From: Bertrand Mansion <email@hidden>
  • Date: Sat, 25 Oct 2003 19:58:20 +0200

Hi,

I have found a way to display an alert panel asking the user whether he
wants to save the changes he made when my tableview selection changes.

I use a class like that :
(most of the code by Steve Dekorte
http://cocoa.mamasam.com/MACOSXDEV/2003/10/2/74520.php )

@implementation MyAlertSheets

- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)theReturnCode
contextInfo:(void *)contextInfo
{
if (sheet == [NSApp modalWindow]) {
[NSApp stopModal];
}
returnCode = theReturnCode;
}

<snip>
@end

int RunSheet(id panel, NSWindow *attachToWin, NSString *title,
NSString *msg, NSString *defaultButton, NSString *alternateButton,
NSString *otherButton)
{
AlertSheetsObj *obj = [[AlertSheetsObj alloc] autorelease];

[NSApp beginSheet:panel
modalForWindow:attachToWin
modalDelegate:obj
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
[NSApp runModalForWindow:panel];
if ([attachToWin attachedSheet]) {
[NSApp endSheet:panel];
}
[panel orderOut:attachToWin];

NSReleaseAlertPanel(panel);
return [obj returnCode];
}

NSLock *onlyOneAlertSheetAtATimeLock = nil;

int RunAlertSheet(NSWindow *attachToWin, NSString *title, NSString
*msg, NSString *defaultButton, NSString *alternateButton, NSString
*otherButton)
{
if (onlyOneAlertSheetAtATimeLock == nil) {
onlyOneAlertSheetAtATimeLock = [[NSLock alloc] init];
}
[onlyOneAlertSheetAtATimeLock lock];

int returnVal = -1;
if (attachToWin == nil) {
returnVal = NSRunAlertPanel(title, msg, defaultButton,
alternateButton, otherButton);
} else {
id panel = NSGetAlertPanel(title, msg, defaultButton,
alternateButton, otherButton);
returnVal = RunSheet(panel, attachToWin, title, msg, defaultButton,
alternateButton, otherButton);
}

[onlyOneAlertSheetAtATimeLock unlock];
return returnVal;
}

<snip>

Then in my selectionShouldChangeInTableView: delegate method, I check
whether changes are done, if yes, show the alert panel and return the
correct boolean according to what the user chose: Save, Don't save, Cancel.

It's working fine except that once the alert panel is closed (user hit a
button), the app needs a second click for the selection in the tableview to
be performed. By performed, I mean NSTableViewSelectionDidChangeNotification
to be posted. SelectionIsChanging is posted correctly.

What does this mean ? Is the app not key anymore ? Why does it need a click
(anywhere) to be reactivated ?

Thanks for your help,

Bertrand Mansion
Mamasam
http://cocoa.mamasam.com
_______________________________________________
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: no fixed variable parameter preceding a variable ... parameter?
  • Next by Date: Re: XCode for Jaguar?
  • Previous by thread: Re: no fixed variable parameter preceding a variable ... parameter?
  • Next by thread: nib files
  • Index(es):
    • Date
    • Thread