Merge pull request #10 from gunyarakun/fix-invalid-return
[cocotron.git] / AppKit / NSWindowScripting.m
blob0715673a6af9901e91bf4309aa99cb7fe0171f0a
1 #import <AppKit/NSWindowScripting.h>
2 #import <AppKit/NSApplication.h>
4 @implementation NSWindow(scripting)
6 -(NSInteger)orderedIndex {
7    NSInteger result=[[NSApp orderedWindows] indexOfObjectIdenticalTo:self];
8    
9    /* Documentation says orderedIndex is zero based, but tests say it is 1 based
10       Possible there is a window at 0 which is not in -[NSApp windows] ? Either way, available windows are 1 based.
11     */
12    if(result!=NSNotFound)
13     result+=1;
15    return result;
18 @end