My Plugins is not working on Musescore4 (especially "cmd()")
I modified a plugin that I used without any issues in MuseScore 3 for MuseScore 4, but Cmd("next-measure") does not work.
The plugin appears in the menu of MuseScore 4, and I believe it is recognized as a plugin. Also, as far as I can see, Cmd("Copy"), Cmd("Paste"), Cmd("Transpose-up"), and Cmd("Transpose-down") all worked correctly.
It did not work in both MuseScore 4.4 and 4.3. Does this mean that MuseScore 4 does not support certain commands?
I have been using MuseScore for about 10 years and finally decided to try creating a plugin. I am a programming beginner and have just started learning Javascript, so if my code is incorrect, I would appreciate it if you could point it out! (I use a lot of transposition commands because I want to write the score in Bb) If I cannot resolve this issue, I plan to continue using MuseScore 3 for the time being.
Here is my environment: PC: MacBook Air (M1) OS: macOS 15.1
Attachment | Size |
---|---|
test.qml | 1.38 KB |
Comments
Known problem
https://github.com/musescore/MuseScore/issues/24673
Should be fixed in 4.5
In reply to Known issue since 4.4 https:… by graffesmusic
Thank you so much for your prompt reply!
I'm looking forward to the next version being released.
The problem with the 'cmd()' function in Musescore 4 is quite strange, and is probably related to the relationship between the two windows (the plugin one and the software one), that is, who has the 'focus'. Similarly, the same problem exists with keyboard shortcuts that may be included in a plugin. In fact, in a non-visual plugin 'cmd()' placed in onRun:{} works perfectly.
However, there are several ways to make this work in a visual plugin. Let's imagine we have a simple plugin that uses a 'button' to do the following:
onClicked :
{
doThis();
doThat();
.....all the operations to be carried out, even with the 'cmd()' function
}
modified like this it works perfectly:
onClicked :
{
quit();
doThis();
doThat();
.....all the operations to be carried out, even with the 'cmd()' function
}
Closing the plugin window allows the 'cmd()' function to be applied. Of course, this is a workaround, and everyone can decide whether to adopt it or not.
The price to pay is the plugin's closure, which is not always desirable...but it's better than nothing.
Another way is to create a plugin...to launch the actual plugin!
It's a little more complicated, but not that much. It's about making a window appear that has a single button with the task of launching the plugin:
onClicked :
{
myMainWindow.showNormal();
quit();
}
.........below, the entire plugin
The window is now the one created by you and not by the plugin.
Magically, the 'cmd()' function starts working again.
In reply to The problem with the 'cmd()'… by ILPEPITO
Last addition: you don't actually even need (unless you want to create a 'launcher' for multiple plugins) to insert a 'button'. Just insert the lines:
myMainWindow.showNormal();
quit();
in onRun:{}.
and delete 'pluginType' from the initial declaration. The plugin will be started directly with your window.
This appears to be fixed in MuseScore 4.5! Thank you, development team!
In reply to This appears to be fixed in… by PitDadPhil
I don't know about Windows (I don't think I'll use this new version for the moment) but in Linux nothing has changed: if you use the option
pluginType: "dialog"
cmd it doesn't work. By trying the simple
cmd("select-all");
nothing happens, and the log file says 'No one can handle the action: notation-select-all'. Anyway, if it works on your OS, good for you...
In reply to I don't know about Windows … by ILPEPITO
It shouldn't depend on the OS
In reply to It shouldn't depend on the OS by Jojo-Schmitz
Perfectly agree with you, but perhaps miracles exist, as long as they are shown... eh eh eh eh
In reply to This appears to be fixed in… by PitDadPhil
The github issue
https://github.com/musescore/MuseScore/issues/24673
was closed however.
In reply to The github issue https:/… by graffesmusic
Very well, it means that everything works. All that remains is to try and see.
In reply to Very well, it means that… by ILPEPITO
Does not seem to be resolved in 4.5.
In reply to Does not seem to be resolved… by graffesmusic
It doesn't seem resolved to me either, even if the proposed alternative remains valid. If I may add a consideration, I believe that in the 'new course' of Musescore the interest in plugin developers (a certainly minority portion of users) is zero, and therefore I would not expect anything positive. There are also some glaring contradictions in this: to give an example, the 'new course' has been oriented towards VSTi, and then (in fact) some properties (such as 'playEvents') that could make their management better are eliminated. Incomprehensible.