A few as yet unanswered questions about the plugin API
I've been developing MuseScore plugins for almost a year now, but there are still a couple of unanswered questions I have. I would gratefully accept your insight into these questions:
1) When EXACTLY should one use curScore.startCmd() and curScore.endCmd() in your plugin code? I find sometimes I think I need it (e.g. when calling cmd()) that in the logs it says that endCmd() had 'no command active' — I'm guessing that means I didn't need to call startCmd()/endCmd(). However, sometimes if I don't use it, MuseScore doesn't see things changing and gives me the wrong values for things. I've also found that I can crash MuseScore if I don't adequately wrap things in startCmd()/endCmd() and then the user hits 'Undo', or you quit MuseScore and it ungracefully crashes.
2) I'm using cursor.add(elem) inside a loop to add a bunch of elements. Can I call startCmd() once before the loop and endCmd() once after the loop, or do I need to wrap each individual call to cursor.add() in startCmd()/endCmd()??
3) What exactly does cursor.inputStateMode = Cursor.INPUT_STATE_SYNC_WITH_SCORE do? I don't entirely understand whether I need to use this or not.
Thanks/Merci/Grazie in advance
Comments
When it's synced, the plugin's action point in the score will be wherever the user has put the cursor, otherwise it will be where your plugin last left your cursor variable pointing to.