views:

17

answers:

0

I am working on application that uses cocotron and the method orderedIndex is not supported in that API. I am trying to recreate the functionality of this method using the orderedWindows method of NSApplication but it seems to be a little different. The method I have created goes through the orderedWindows array and checks each element with the window that was passed in and if it finds a matching window it return the index of the window. The method I have created seems to work if I add one to the index but I am not sure why I need to do this and I am also concerned that because of this hack it will not work in all cases. Can anyone explain why this might be the case or link me to some documentation that describes where the cocoa method orderedIndex gets its value from. Does it get the value from some array? I assume its not orderedWindows.

My method is written in lisp using a cocoa bridge. If anyone is interested in the lisp code here it is. Method calls starting with #/ are calls to cocoa methods:

(defun ORDERED-WINDOW-INDEX (Window)
  (let ((window-array  (#/orderedWindows (#/sharedApplication ns::ns-application)))) 
    (dotimes (i (#/count window-array))
      (let ((array-window (#/objectAtIndex: window-array i)))         
        (if (equal window array-window)            
         (return-from ordered-window-index (+ 1 i)))))
 (return-from ordered-window-index nil)))