Select next chord after current selection
I need my plugin to select the next chord after the current selected chord(s):
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)
In reply to Wouldn't cmd("next-chord")… by jeetee
Thanks jeetee, good idea! I wasn't aware of
cmd()
.It works like this:
BTW: The only list of commands I've found so far is here at GitHub. I didn't found official documentation.
In reply to Thanks jeetee, good idea! I… by nurfz
That txt is old and obsolete.
Here's the real 3.x list: https://github.com/musescore/MuseScore/blob/3.x/mscore/shortcut.cpp#L30
The action name you have to place as the argument for cmd() is the 3rd entry into the struct
In reply to That txt is old and obsolete… by jeetee
Thanks!
PS: To get a list of all commands: