I’d like to be able to make a specified document window first responder by selecting it’s name in a table rather than choosing it in the Windows menu. How do I reference a document window by name?
Thanks,
Greg
I’d like to be able to make a specified document window first responder by selecting it’s name in a table rather than choosing it in the Windows menu. How do I reference a document window by name?
Thanks,
Greg
I figured it out, in case it might help anyone else - you never know.
In the Document script:
property theFirstTime : true
on windowDidBecomeKey_(aNotification)
set theOpenWindow to aNotification's object
if theFirstTime = true then --is it the first time the window appeared (file just opened)?
current application's NSApp's delegate()'s registerLog_(theOpenWindow) --calls the method in the App Delegate script
set my theFirstTime to false --so it only happens the first time the file is opened
end if
end windowDidBecomeKey_
In the App Delegate script:
property openFileList : {}
on registerLog_(theOpenFile)
set my openFileList to openFileList & theOpenFile --make a list of the currently open document windows which populates a table
end registerLog_
on selectedRow_(sender)
tell theArrayController1
set theSelectedRow to selectionIndex() as integer + 1 --the row number which correlates to the item in the list
end tell
(item theSelectedRow of openFileList)'s makeKeyAndOrderFront_(me) --makes key the document window selected in the table
mainWindow's makeKeyAndOrderFront_(me) --returns key to the window with the table
end selectedRow_
So now the first responder is the document window I selected in the table and the key window is the main window with the table containing the list of open files.
If anyone sees a better way please let me know. If you can make a window first responder without making it key I could skip the step of making it key and returning key to the main window.
Greg