Welcome, Guest. Please Login
Rorohiko Workflow Resources
  Welcome the Message Board of Rorohiko Workflow Resources. To register, please e-mail [email protected] - automatic registration has been turned off because of relentless spambots and spammers. This Message Board is not actively monitored. If you have an urgent question, please e-mail [email protected]. If you post it here, it will probably be many weeks before we notice.
  HomeHelpSearchLogin  
 
Page Index Toggle Pages: 1
Send Topic Print
Observing the selection with a ScriptUI palette (Read 5160 times)
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Observing the selection with a ScriptUI palette
10/06/08 at 08:09:24
 
Below a copy of some info I passed on to some APID developers - it's pretty useful, so I duplicated it here...

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:

Code:
//----

var gPalette;
var gField;
var gController = theItem;

function CreatePalette()
{
  gPalette =
    new Window(
      "palette",
      "What is it");
  gField = gPalette.add("statictext",[0,0,200,20],"testfield");
}

if (gPalette == undefined)
{
  gController.setDataStore("$GROUP_EVENTS$",true);
  CreatePalette();
  gPalette.show();
}

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).

Cheers,

Kris
Back to top
 

Kris
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print