bug-gnustep
[Top][All Lists]
Advanced

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

[bug #25472] NSDocumentController doesn't bring an already-open document


From: Doug Simons
Subject: [bug #25472] NSDocumentController doesn't bring an already-open document to the front
Date: Tue, 03 Feb 2009 21:33:17 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1

Follow-up Comment #3, bug #25472 (project gnustep):

Okay, looking at this again I see that I gave a bad report about what I was
seeing (stepping through slowly from gdb gives somewhat different window
behavior than running without breakpoints). So now when I run normally the
window IS coming to the front, but NOT always becoming key (or possibly
becoming key briefly before the previous key window is made key again).

I'm not sure what's causing the odd key window behavior, but it behaves fine
(becomes the key window every time) when the document is opened by selecting
its name in a window and clicking a button in that window. The failure to
become key window only occurs when the document is opened by selecting it from
an open panel that was brought up from a menu.

The code to open the document is essentially identical in both cases, so I
suspect an odd interaction somehow either from the menu click or from the
modal open panel that was just displayed. 

This isn't a very critical issue at this point, but in case anyone wants to
think about this puzzle, here is my code (slightly condensed):

Code that WORKS 100% of the time, called by clicking a button (or
double-clicking an item in an NSTableView) in a window containing an
NSTableView with a list of document names:

- (IBAction) openFiles:(id)sender {
    NSEnumerator *rowEnumerator = [fileTableView selectedRowEnumerator];
    NSNumber *currentRow = nil;
    NSArray *filenames = [self filenames]; // array of document filenames

    while (currentRow = [rowEnumerator nextObject]) {
        NSString *fileName = [filenames objectAtIndex:[currentRow
intValue]];
                
        [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfFile:fileName display:YES];
    }
}

Here's the code that OCCASIONALLY WORKS, but more often brings the document
window to the front but FAILS to make it the key window. This is called as the
action of a menu item:

- (IBAction) openScript: sender {
    NSOpenPanel *openPanel = [NSOpenPanel openPanel];
        
    [openPanel setAllowsMultipleSelection:YES];
    if ([openPanel runModalForDirectory:[self currentDirectory] file:nil
types:[NSArray arrayWithObject:@"filetype"]] == NSOKButton) {
        NSArray *filenames = [openPanel filenames];
        NSEnumerator *objectEnumerator = [filenames objectEnumerator];
        NSString *filename = nil;
                
        while (filename = [objectEnumerator nextObject]) {
            [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfFile:filename display:YES];
        }
    }
}

Like I said, I don't see anything significantly different about the two
pieces of code other than the way they are invoked. The failure to become the
key window occurs whether or not the document was already open (earlier I
thought that was a factor, but apparently not).



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?25472>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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