My scriptable app knows different types of windows, based on the ObjC classes SearchWindow
and ResultWindow
.
I cannot figure out how to make their specific script classes appear when I use get windows
- they come back as generic window
types.
Here’s the .sdef, slightly shortened:
<dictionary title="Find Any File Terminology">
<suite name="Standard Suite" code="????" description="Common classes and commands for all applications.">
… here's all the stuff from /System/Library/ScriptingDefinitions/CocoaStandard.sdef
</suite>
<suite name="FAF Suite" code="FAF2" description="Find Any File commands">
<class name="Find Any File" code="FAFa" inherits="application" description="The application's top-level scripting object.">
<cocoa class="NSApplication"/>
<element type="document">
<cocoa key="orderedDocuments"/>
<accessor style="id"/>
<accessor style="index"/>
</element>
<element type="window" access="r">
<cocoa key="orderedWindows"/>
<accessor style="id"/>
<accessor style="index"/>
</element>
</class>
<class name="search window" inherits="window" code="FinW" description="A window with search rules and a Find button.">
<cocoa class="SearchWindow"/>
</class>
<class name="results window" inherits="window" code="ResW" description="A window containing a list of files and folders.">
<cocoa class="ResultWindow"/>
</class>
</suite>
</dictionary>
Do I have my declarations wrong?
I can verify, by overwriting -[NSApplication orderedWindows]
, that it’s really returning objects of my two window classes.
update
I guess I had my expectations wrong. I thought that the specific window types would be identifyable as such, i.e. that they’d appear as e.g. “search window id xxxx” instead of just “window id xxxx”. But that’s never the case for subclassed items, is it?
So, how is an AppleScript user supposed to identify the type of a subclassed object, then? I see that Script Debugger doesn’t tell me, either, when I try this, for instance, with the old Sketch example - the “graphics” objects do not dynamically identify them as their real classes, but as the classes declared by that property.
Here’s what SD shows:
As you can see, “graphics” only shows the basic super class members, and only the “text areas” shows the specific members of the subclass.
Is that normal, or is that just a bad example implementation?