On Dec 12, 2007 6:38 AM, Adam R. Maxwell <[EMAIL PROTECTED]> wrote:
>
> On Dec 11, 2007, at 12:39 PM, Christiaan Hofman wrote:
>
> >
> > On 11 Dec 2007, at 9:30 PM, Adam R. Maxwell wrote:
> >
> >> Is there any way we can get rid of the finalize changes stuff or
> >> endEditingFor:? I think we're bypassing NSDocument and the
> >> formatters in some cases, because of legacy behavior. I'm thinking
> >> of -[BibEditor windowShouldClose:] in particular, but
> >> forceEndEditing is another tricky part to handle correctly.
> >>
> >
> > I don't think so. Without binding, I think explicitly ending editing
> > is the only way to commit. Why do you say we're bypassing NSDocument?
>
> Not necessarily NSDocument, but when you save, it posts a notification
> that calls finalizeChanges: on open editors, right? That does a brute
> force end editing, and the document is saved in spite of any alerts in
> the editor; I think we should fail to save. It seems preferable to do
> something conceptually like this in the document:
>
> - (BOOL)canSaveDocument{
> NSWindowController *wc;
> NSArray *editors = [self windowControllers];
> for(wc in editors) {
> if ([wc isBibEditor] && [wc didValidate] == NO)
> return NO;
> }
> return YES;
> }
>
> - (IBAction)saveDocument:(id)sender
> {
> if ([self canSaveDocument])
> [super saveDocument:sender];
> else NSBeep()
> }
>
That would probably be better, if it could work (see below).
>
> where didValidate would simply check [[self window]
> makeFirstResponder:nil]. That should cause any formatters to fire and
> check their contents, with no forceEndEditing. Same thing in
> windowShouldClose; it should return NO if [[self window]
> makeFirstResponder:nil] fails, not if it has an attached sheet as a
> side effect of the finalize call.
>
> There's likely stuff I'm forgetting or just don't see, but it seems
> like that could simplify the validation code at least. I can't figure
> out editing; we have a mix of NSControl/NSText/NSFormatter delegates,
> and also the recordChangingField:toValue: and
> userChangedField:from:to: stuff...it's not clear which is used for what.
>
> --
> adam
>
I also don't like all the different validations. Note that
recordChangingField:... and userChangedField:... have nothing to do with
validation, they are just wrappers around changing a value and whatever
needs to be done (like autogeneration and scripthooks).
But I don't think we can put the validation in one place. Some validation
happens only when the value is committed, as it cannot be handled by the
formatter (e.g. the crossref chain problem). Although that could perhaps go
into control:textShouldEndEditing:.
What about a window close when the app quits? That does not use
windowShouldClose.
Christiaan
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop