2 Replies Latest reply on Feb 26, 2009 9:05 AM by YiannisVs

    How to get ISelectionManager

    YiannisVs Level 1
      Hi,<br /><br />I add a new javascript method to IDocument object, everything works ok and I can call the method through a jsx.<br /><br />var myDocument = app.open(myFile,true);<br />myDocument.dosomething();<br /><br />Here is a part of code<br /><br />ErrorCode CS4ServerScriptProvider::HandleEvent(ScriptID eventID, IScriptEventData* data, IScript* parent)<br />{<br />.....<br />...<br />// To get the IDocument I use this call<br />InterfacePtr<IDocument> document(parent, UseDefaultIID());<br />..<br />..<br />}<br /><br />My question is how to get the selection manager for this document, the following statement return always null.<br /><br />selectionManager = InterfacePtr<ISelectionManager>(Utils<ISelectionUtils>()->GetActiveSelection()); <br /><br />also the following call returns null <br /><br />GetExecutionContextSession()->GetActiveContext()->GetContextSelection();
        • 1. Re: How to get ISelectionManager
          Mfi Previon Level 1
          Hi John,

          As it seems, there is no "selection" property in javascript on the document object for InDesign Server. This leads me to the conclusion that selection is UI related and is not used in InDesign Server that way.

          There are other ways to manipulate items in InDesign Server, e.g. via corresponding interface-methods (C++ code) that take an UIDList as parameter.

          So you have to know what items to process; or I think you could attach your javascript-dosomething()-method directly to the desired items (e.g. PageItem instead of Document) and call the method on them.

          Kind Regards,
          • 2. Re: How to get ISelectionManager
            YiannisVs Level 1
            Thanks for your reply.<br /><br />I convert an InDesign Desktop plugin to InDesign server plugin.<br /><br />Your observation makes sense, also the Utils<ILayoutUIUtills>()->GetFrontDocument() does not work, because for the server there is not foreground document (active). <br /><br />If anyone want to comment on that is welcomed.<br /><br />Best Regards<br />John