I've got this ScriptUI interface (javascript based), and now I wonder if it would be possible to change one of its button captions depending on whether anything is selected or not, in the active document (would also have to be updated if the user selects or opens another document).
1. Is it possible to write event listeners for this?
2. Would it be possible to include this in the same script as the rest of the Script UI interface code (that is, I'd prefer avoiding a separate file in the startup folder).
3. What's the best source of information regarding events, which ones there are, and how to handle them in javascript?
Andreas
1. Yes. The selection events work well in my experience.
2. Yes, you don't have to add them at startup. You can do something like:
app.addEventListener("afterSelectionChanged", selectionChangedFunction);
before you open your window. Remove the listener in the onClose event of the window. I think you'll have to have some error trapping in the selectionChangedFunction to deal with app.selection erroring after a document close or during a revert.
3. See this thread for an extension that lets you see events as they're happening.
Jeff
North America
Europe, Middle East and Africa
Asia Pacific