Select next chord after current selection

• Jun 23, 2021 - 14:42

I need my plugin to select the next chord after the current selected chord(s):
screenshot-2021-06-23-15-27-50.png

I know that I can access and set the selection with curScore.selection.select(element) (documentation).

But how to get the next chord element after the current selection? I tried this:

    function proceedToNextChord() {
        var cursor = curScore.newCursor()
        cursor.rewind(2) // goto end of selection
        console.log(cursor.next()) // next segment, logs false ("end of score")
        var element = cursor.element // returns null
        if (element) {
            curScore.selection.select(element)
        }
    }

But it looks like cursor.next() cannot go beyond the current selection. Any ideas on how to get the next chord?


Comments

Wouldn't cmd("next-chord") work out? Then select-next followed by select-prev will likely select that.

Just like how I would do it in the UI manually:
1. Press right arrow key
2. Press Shift+right arrow (selects this + next)
3. Press Shift+left arrow (removes next from selection again)

Do you still have an unanswered question? Please log in first to post your question.