This content has been marked as final. Show 14 replies
in VB on PC - there is no problem :)
but in JS ... I think you can use APID from ROROHIKO:
I use APID from Rorohiko. Excellent stuff. I will try the observer functionality to see if I can trigger changes to the floating palette.
It's not really the observer functionality you want, it's the events.
Of course. Thank you for the help.
Still no joy...
APID does not add any events to the palette object of ScriptUI. They are added to the document. Bob corrected me about APID providing new events, not observers, but provided no insight ;) APID allows me to do something based on certain document events, but how is an active ScriptUI palette targeted?
It makes sense to observe the document from the palette, but this may be something I can only do with the plug-in SDK.
I'd like some more considered responses if anyone has a perspective.
Here what I found in feature-development-with-scripting.pdf (FAQ chapter):
b Can an ExtendScript-based (ScriptUI) panel react to the current selection?
There are only a few events that can update a ScriptUI panel, and changing selection is not one
of them. There are three ways a ScriptUI panel can get updated:
*Idle handler — This works only while a script is running. A script can send an idle event to
a ScriptUI pane and have it respond to the event and update. This probably will get used
primarily for filling in progress indicators in a progress bar as a longer script runs.
*Any event in InDesign that can invoke a script — This includes start-up scripts, some document
events (save, open, close, export, etc.), menu events, and just running scripts from the
*ScriptUI events — If you interact with the panel in any way (like moving it, resizing it, and
clicking a button), a script can be fired to update the panel contents.
That is great, thank you, Kasyan.
How do you target the floating palette after an event is triggered? Is it one of the windows of the application?
Kris Coppieters from rorohiko.com has solved the problem using features from Active Page Item Developer (APID). This actually gets around the limitations of ScriptUI alone by allowing a panel to receive updates based on the user selection.
Thank you, Kris.
I love APID.
Could you please tell me in few words how exactly you solved it. I have a demo version of APID and explored tutorials in cookbook, but it seems to be beyond my level.
APID actually makes it quite easy. All you'd do is give some object a
subjectSelected event with the subject list of "*". In the event script
you would just update the fields of the palette with the info you need...
Thank you, Harbs.
Below roughly what I sent to Simon - it is not a full solution, but demonstrates the techniques you need.
With APIDToolAssistant installed and a document open, create a page item on the pasteboard; this page item will be used as a 'controller' for this demo. Select it and bring up the APID ToolAssistant palette.
Set the list of subjects to "*"
Set the event filter to "subjectSelected#myLittlePaletteEngine, subjectDeselected#myLittlePaletteEngine".
This captures the selection and deselection events for all page items, and routes them into a persistent engine (myLittlePaletteEngine) for handling.
Because the engine is persistent, it will 'remember' gPalette and gField on subsequent events after they have been created the first time around.
Set the script to:
var gController = theItem;
"What is it");
gField = gPalette.add("statictext",[0,0,200,20],"testfield");
if (gPalette == undefined)
gField.text = app.selection.toString();
This does work for 'page item' selections - it won't work for text selections. To make that work too, you need to change the event filter to "*#myLittlePaletteEngine" (* is a wildcard and matches all events, including idle - which is used to update the text selection info).
This last method (relying on idle) is not terribly good or efficient; I am currently looking how I could avoid the need for capturing 'idle' in version 1.0.46 (which will support CS4).
Thank you, Kris, for responding to Kasyan's message. I didn't notice the update to the thread until now.
My apologies, Kasyan. I would always be happy to share solutions.