Change the Current Score in a Plugin
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?
Comments
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 cmd() actions always apply… 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:
https://github.com/calculuswhiz/musescore-utils/blob/master/ValidComman…
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 Thanks, the next-score… by barryw12
Methinks the answer to your question lies at the bottom of the of the cmd.cpp file in the Musescore github. See @ https://github.com/musescore/MuseScore/blob/master/src/libmscore/cmd.cpp starting on line 4478.
In reply to Methinks the answer to your… by rocchio
I have had a look at cmd.cpp, but it does not contain the text (and hence the command) "next score ".
In reply to I have had a look at cmd.cpp… 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:
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 Thanks, the next-score… by barryw12
You might want to search the sources of the version you're using; master is the development version of 4.x, where indeed many shortcut actions are not (yet) present.
See https://github.com/musescore/MuseScore/blob/3.x/mscore/shortcut.cpp#L30… instead
In reply to cmd() actions always apply… 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: https://github.com/calculuswhiz/musescore-utils/blob/master/ValidComman…
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
In reply to I have finally got round to… by barryw12
The URL for the above was cut off. Here is the complete link:
https://github.com/calculuswhiz/musescore-utils/blob/master/ValidComman…
In reply to The URL for the above was… by mslinn
Still.. way better to use the link to the actual sources above than this link to a compiled list of some version at some point in time.