Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

current cursor position add xmlComments

Community Beginner ,
Dec 10, 2018 Dec 10, 2018

Hi Friends,

How to add current cursor position in the xmlComments tag. Can anyone help me, please? I can't seem to find the answer in the scripting guide in either the Text or Notes chapters.

Thanks,

SK

TOPICS
Scripting
908
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 11, 2018 Dec 11, 2018

Try the following code

if( app.selection[0].constructor.name == "InsertionPoint" && app.selection[0].associatedXMLElements.length == 0)

     alert("The insertion point is not in a tagged textt")

else

     app.selection[0].associatedXMLElements[0].xmlComments.add("hello", app.selection[0])

Make sure the current selection is insertion point.

-Manan

Translate
Community Expert ,
Dec 10, 2018 Dec 10, 2018

What do you mean by current cursor position? The XMLComment that you want added would be added to which node? Does you document already has a structure, i.e. tags applied to frames or text?

Can you give a screenshot showing what you want to be added?

-Manan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 10, 2018 Dec 10, 2018

Hi Manan,

Thanks you replay.

1. Before image:

Before.PNG

2. After image: Here with i need to add xmlcomment tag.

I need after.PNG

For above for your reference.

Thanks,

SK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2018 Dec 11, 2018

Try the following code

if( app.selection[0].constructor.name == "InsertionPoint" && app.selection[0].associatedXMLElements.length == 0)

     alert("The insertion point is not in a tagged textt")

else

     app.selection[0].associatedXMLElements[0].xmlComments.add("hello", app.selection[0])

Make sure the current selection is insertion point.

-Manan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 11, 2018 Dec 11, 2018
LATEST

Hi Manan,

Thanks your replay. Your code working super .

Thanks,

SK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 10, 2018 Dec 10, 2018

Hi,

    

     I think its possible for xml Elements not for xml Comments.  XML comments are hidden tags.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines