How to configure OSX screen saver configuration table?

I am working on a screen saver for OSX (Mountain Lion), and I am having problems setting up a configuration sheet (therefore, when a user clicks "Screen Saver Settings ..." in System Preferences, my settings appear), It seems that there are only two or Three tutorials on writing OSX screen savers anywhere on the Internet, and they’ve all done it for several years, so the material is not completely translated into OSX 10.8 and Xcode 4.

First of all, in my ScreenSaverView.m file, I have:

 - (BOOL)hasConfigureSheet { return NO; } - (NSWindow*)configureSheet { return nil; } 

... and yet, in System Preferences, the "Screen Saver Settings ..." button is still available for click (nothing happens when pressed), but not disabled, as in the Arabesque screen saver.

What are the steps when creating a configuration page when a button is clicked and why the button is not currently disabled?


Edit:

I understood why the Screen Saver ... button was not disabled. I forgot to enable -(BOOL)hasConfigureSheet; to the ScreenSaverView.h file. However, my question about how to get the configuration sheet remains.

+4
source share
1 answer

First of all: be sure to include ScreenSaver.framework in your project; it provides the required ScreenSaverView and ScreenSaverDefaults classes.

You say that you already have a file called ScreenSaverView.m . A couple that you also say that you need to export your -hasConfigureSheet method to disable the "Screen Saver Settings ..." function. This makes me wonder if you have subclasses of ScreenSaverView , as you should have done. (Instead, did you use a subclass of NSObject ?) ScreenSaverView export methods for you, such as -hasConfigureSheet . You must subclass it and override the appropriate methods in it.

A couple more things:

You had to include in the xib project a file containing the user interface for your configuration sheet, and you had to provide an IBOutlet in the interface of your subclass to link to the panel and the interface elements that it contains (those for which you actually need an exit, i.e).

Finally, your -configureSheet method should get a configuration sheet similar to this (in this example, configSheet will be one of your IBOutlet s):

 if (configSheet == nil) { if ([NSBundle loadNibNamed:@"myConfigSheet" owner:self] == NO) { NSLog(@"load config sheet failed"); } } // then retrieve your defaults and set up your sheet; you should // be working with ScreenSaverDefaults, a subclass of NSUserDefaults. // then return 'configSheet' 

Edit:

Sorry in advance if I am going to tell you what you already know, but you said that you had difficulties in configSheet , and therefore I just close all the databases.

In My_ScreensaverView.h declare a socket for your panel:

 IBOutlet id configSheet; 

Note that I used id instead of NSWindow * or NSPanel * , simply because I don’t know which class you are using for the sheet. (Ideally, the sheet should use NSPanel.)

In the nib file, verify that File Owner is an instance of My_ScreensaverView . You can determine this by selecting the icon for this object, and then using the Identity Inspector to specify the class.

Make a connection between the configSheet connector and the panel. One way to do this is to hold down the Control key while dragging and dropping from the File Owner object onto the window or panel icon, and then select configSheet from the popup that appears.

As always, good luck with your endeavors.

+5
source

All Articles