discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom options during save in a document app


From: Wolfgang Lux
Subject: Re: custom options during save in a document app
Date: Sun, 7 Oct 2012 09:33:33 +0200

Riccardo Mottola wrote:

> thanks Wolfgang, I have some dirty, but almost working code. I shuffle the 
> view on panel creation, I was unablle to dynamically
>> Riccardo Mottola wrote:
>> 
>> 
>> You might add a declaration
>> @interface NSDocument(Hidden)
>> - (void)changeSaveType: (NSString *)fileType;
>> @end
>> to get rid of the warning.
> apparently it is of type (id)sender. Read below.
>> The new file type is passed as argument to the -changeSaveType: method. 
> It appears instead that the sender is passed: NSPopUpButton, I printed out 
> the sender.

Ummm, sorry, you are of course right. I got confused at some point.

> I made a hack now to use pos.1 and pos2.. just to test (it is bad of course, 
> since the order and generally the filetypes might change). It shows the 
> concept can work, I will commit it so you can see it and i can test it on 
> gnustep too.

No need to use hacks. The proper way to find out the selected file type is 
[[sender selectedItem] representedObject].

> Besides the file-type hack, other two things need a solution:
> - on load, I don't know how to "initialize" the values. In my old code, I 
> issued a message to simulate a "click" on the popupbutton, which thus 
> syncronized all the values. Here I don't have a reference to the popupbutton 
> to click! Also I can't assume that the default filetype is TIFF or JPEG for 
> example

Not sure what your problem is here. There is nothing you need to initialize. 
NSDocument automatically selects the current document type (as returned by the 
-fileType method) for you.

> - the document "remembers" how it was last saved! so once it has a filetype, 
> the next time you do saveAs it removes the accessory view!. Also TextEdit 
> doesn't behave this way, so I fear it is something I do. Perhaps the 
> accessoryView doesn't get regenerated? I don't know, the documentation says 
> it gets released, thus I suppose it is logically recreated the next time.

At least under GNUstep the pop up button is created just once and retained by 
the NSDocument class. The next time you use the save panel the pop up button 
will be reused and set as accessory view of the save panel before 
-prepareSavePanel is called. If that doesn't work for you, you seem to have a 
major bug in your code.

Wolfgang




reply via email to

[Prev in Thread] Current Thread [Next in Thread]