use "word under cursor" in script

TXS - Help
  • Marcel

    Marcel - 2014-01-10

    Hey ho!

    Currently i'm writting a script, that marks a word as a indexentry. But i have to select the word and then i can use the macro. I would like to have, that the word under the cursor is used. Therefor i found this feature requests

    However the following code produces an error

    idx = cursor.selectedText(WordUnderCursor)

    The error

    Uncaught exception at line 1: ReferenceError: Can't find variable: WordUnderCursor
    Backtrace <anonymous>()@:1

    According to the feature requests the wordundercursor function is implemented. Can anybody help me?

    Thank you for your help.

  • Tim Hoffmann

    Tim Hoffmann - 2014-01-10

    There are two things:

    1. you mixed up selection and retrieving the text
    2. to access the cursor movement related constants, you have to use the cursorEnums variable

    This should work:
    idx = cursor.selectedText()
  • Marcel

    Marcel - 2014-01-11

    Thank you, works perfectly.

    Yesterday i'm slow on the uptake. It makes sense, that i have first to select the text and then retrieve.

    I wanted to add the script and other to the wiki page (, but i haven't the permission to edit this page.

    Last edit: Marcel 2014-01-11
    • Tim Hoffmann

      Tim Hoffmann - 2014-01-11

      Should now be possible

  • Marcel

    Marcel - 2014-01-11

    Thanks, done, closed.


Log in to post a comment.