Re: Sheets and NSPreferencePane
Re: Sheets and NSPreferencePane
- Subject: Re: Sheets and NSPreferencePane
- From: Thomas Harrington <email@hidden>
- Date: Sat, 20 Jul 2002 12:24:14 -0600
On Friday, July 19, 2002, at 04:47 PM, Thomas Harrington wrote:
I'm trying to load a sheet from an NSPreferencePane subclass--
something like the result of the "Software Update" pref pane's "Show
Log..." button. In the pref pane class I have the following:
[NSApp beginSheet:configurePanel
modalForWindow:[[self mainView] window]
modalDelegate:self
didEndSelector:@selector(configureSheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
In this call, "configurePanel" is an NSPanel subclass that I can verify
has been loaded from its nib already (e.g. by experimentally replacing
this snippet with a call to tell it to makeKeyAndOrderFront).
Just to supply some more detail...
I tried replacing [[self mainView] window] with [NSApp mainWindow], but
I still get the "Modal session requires modal window" error.
Also, for debugging purposes I'm not actually loading this in System
Preferences, instead I have a wrapper application that loads the
preference pane into an NSWindow in its awakeFromNib:
- (void)awakeFromNib
{
NSView *prefView;
NSString *pathToPrefPaneBundle =
@"/Users/tph/Projects/Foo/build/Foo.prefPane";
NSBundle *prefBundle = [NSBundle bundleWithPath: pathToPrefPaneBundle];
Class prefPaneClass = [prefBundle principalClass];
NSPreferencePane *prefPaneObject = [[prefPaneClass alloc]
initWithBundle:prefBundle];
if ( [prefPaneObject loadMainView] ) {
[prefPaneObject willSelect];
prefView = [prefPaneObject mainView];
/* Add view to window */
[[mainWindow contentView] addSubview:prefView];
[prefPaneObject didSelect];
} else {
/* loadMainView failed -- handle error */
NSLog(@"Error loading main view...");
}
}
_______________________________________________
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.