Change the Current Score in a Plugin

• May 8, 2021 - 12:10

If you use a command such as cmd("copy"), the copy action takes place on the current score.
After using a cmd("Copy" ) I would now like to apply a cmd("paste") so that the copied material is pasted into a different score.

How can you make a different score the current score in a plugin?
Or alternatively is there a another way to make a command apply to a different score?


cmd() actions always apply to the current score (just like in the program). I'm not sure how to change the current score (you could try the next-score command?)

It seems that curScore itself is read only, as is the scores array.

In reply to by jeetee

Thanks, the next-score command will do the trick. It cycles through the open scores making the next score (to the right) in the interface the active/current score. When called when the last (right most) score is current it will cycle back to the first (left most) score in the interface.

I have a query though. I use the following reference for a list of available commands:…

But this list does not appear to have the next-score command listed. Is there another more complete list of commands? If so could you provide a link.

In reply to by barryw12

You're right. Interesting. I just tried a search for the text "next score" in the whole repository.

You can see what appears to be the "Shortcuts" defined for the user interface in the file
MuseScore/src/framework/shortcuts/data/shortcuts.xml. Line #830 defines "next-score."

In the file src/plugins/api/qmlpluginapi.cpp I see the source code:

void PluginAPI::cmd(const QString& s)

I haven't tried to trace down if the shortcut list in the XML file is what shortcuts() is processing. But that directory for "shortcuts" contains files which suggests to me that that XML file may hold some, or all, of the keys (literally and figuratively!). src/framework/shortcuts/

In reply to by jeetee

I have finally got round to following some of the links presented above.

The link(which I used initially for commands) is an incomplete and unhelpful reference:

The pluginAPI appears to use shortcut.cpp for its list of commands. This it would appear to be a complete list of commands available through the plugin API. shortcut.cpp also contains a brief description of each command which is absent in the list provided by calculuswhiz. shortcut.cpp also provides information as to which UI states each command is valid for.

shortcut.xml is likely to be essentially the same list of commands as contained in shortcut.cpp, but it only contains the shortcut name and the key strokes to invoke the command from the user interface.

The pluginAPI then (after checking that the command string is valid by using shortcuts.cpp) invokes a 'cmd' defined in musescoreCore.h

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