Ah, you’re talking about the Xojo event; fine.
Here are the three parameters’ explanation:
• Event As AppleEvent: this is the object representing the actual AppleEvent. This is where, for example, you can get the file the user wants to print:
(like this, it’ll work for only one item at a time)
This is where all data pertaining to the event can be found, once you’ve figured out which event is asked (from the other 2 parameters).
• EventClass as string: the class of the AppleEvent. Consider this as being a group of defined events (see later). Common values are: “core”, “aevt”, “misc”,…
• EventID as string: the ID of the event.
EventClass and EventID are both a 4 characters string to identify the event.
The EventClass is represents a group containing EventIDs.
To illustrate this, here are some common AppleEvents you have on MacOS:
AppleScript verb (as entered in a script): get
AppleScript verb: set
AppleScript verb: open
AppleScript verb: close
AppleScript verb: duplicate
As you can see, the “aevt” class (suite) encloses a variety of EventID values, each representing a specific event, as does each other class.
Note that, for example, an event with class=aevt and ID=quit is meant to quit an app, but an event with class=core (or anything else) and ID=quit would not be defined system-wide and only your app would know its meaning (if you choose to define it).
Each event then defines its set of properties. For instance, “open” (class=aevt, ID=odoc) has a parameter to know which file(s) must be open, while “move” (class=core, ID=move) typically would need to know which item(s) to move and where to move them (i.e. 2 parameters, and a third optional (properties to set along the way)). The direct parameter (usually the main one) is accessed using the “----” special string.
In summary, here’s one way you can handle a “print file(s)” event in Xojo (in the HandleAppleEvent event):
if eventClass="aevt" and eventID="pdoc" then '"pdoc" in the "aevt" suite is for the "print" command
dim aed As AppleEventDescList 'A list of parameters (valid if there are several items to print)
dim f As FolderItem
aed=theEvent.DescListParam("----") 'Attempt to get a list of items
if aed=nil then 'When nil, it means a single item has been passed (it's like an array in Xojo: for a single item, you use a straight variable)
f=theEvent.FolderItemParam("----") 'The single file to print
PrintDocument f 'Call the method to print the passed folderitem
else 'aed is not nil: we have several files to process
for i as Integer=1 to aed.Count 'Index for AppleEvent functions are usually 1 based
PrintDocument f 'Print each file
Return True 'Tell the caller application that the event was understood and handled.
(juste note I’ve written this right now in Xojo for this example, but I didn’t actually ran it to test for errors)