Re: Using alerts with Preference Panes
Re: Using alerts with Preference Panes
- Subject: Re: Using alerts with Preference Panes
- From: Pete Gontier <email@hidden>
- Date: Thu, 16 Dec 2004 18:54:19 -0800
circa 12/16/04 9:22 AM, "Pete Gontier" <email@hidden> wrote:
>>> I'm creating a preference pane, and I need an alert to show up if user
>>> information was incorrectly supplied. I tried using the NSBeginAlertSheet
>>> with my sample application and it worked fine, but when I moved the code
>>> over to my preference pane, the compiler did not seem to recognize my
>>> NSWindow (_window or a new outlet for window).
>>>
>> You can't attach the alert panel to your window, because System
>> Preferences.app takes the view from your window and attaches it to it's own.
>> Use [NSApp mainWindow]. This works.
>>
> Unfortunately, it did not make any difference for me. I too am attempting to
> post sheets onto the System Preferences window. I have a view in the window
> which I keep track of only so that I can call its window method to get a value
> I can pass to sheet-oriented methods. When I pass this value to the
> beginSheetForDirectory method of NSSavePanel or NSOpenPanel, everything works
> fine. However, when I pass this value to NSBeginAlertSheet, some truly weird
> stuff happens. I get a stand-alone alert instead of a sheet, and the System
> Preferences window disappears. I think the window is being hidden; selecting
> it from the Windows menu shows it again.
The problem was that I was trying to post a sheet against the main window
from within the didEndSelector of NSSavePanel. The solution for now appears
to be performSelector:withObject:afterDelay: to defer the posting of the
sheet for 0 seconds (the goal being to make the run loop iterate rather than
wait for some period of time). I am in denial that such a common task needs
to be done in such an obscure and indirect fashion, so if you have a better
idea, please let me know.
--
Pete Gontier
http://www.m-audio.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden