What does where my selection is outside the win mean?
Oops, that was supposed to say: outside the window.
Basically I am selecting text in a textframe, and the selected text must be presented in the palette-window.
It seems like they put the window creation in a function, and call for that function on event? on click - reload window?
I'll give that a try, not very keen on having clients to install other plugins as well.
Here I posted a sample document for you (CS3).
Kris gives a very good explanation of how it works. I recomend you to download and install demo version of APID Toolkit, open the sample and try to select different objects.
In the What is it palette you'll see the class of the selected object.
Open the APID panel.
List of subjects: * -- means that you "watch" all objects
Subject filter: "subjectSelected#myLittlePaletteEngine, subjectDeselected#myLittlePaletteEngine" — means that every time you select or deselect an object, the script below will be triggered. For the first time, it creates a palette (gPalette) then it only updates the text property of the static text (gField).
#myLittlePaletteEngine — means that the script should run in a persistent engine (it's necessary for a palette).
For developing you need APID Toolkit (the price is about $150, fully functional demo period is about 20 days)
For clients you'll need APID ToolAssistant (the price is $25)
Hope this helps.