[SOLVED] Using the RewindMode enum

• Apr 20, 2024 - 11:00

I'm working on a plugin that has to rewind the score in a few places, using the function cursor.rewind().
To pass a parameter to this function, I would like to use the enum RewindMode, but when I try to use it, I get the following error message:

13:-1: ReferenceError: RewindMode is not defined

I attached an example of me trying to use this enum.

What do I have to do in order to use this enum in a plugin?

Attachment Size
TEST.qml 240 bytes

Comments

I get

Plug-In Details:
Menu Path: Plugins.TEST
Version: 1.0.0
Description: TEST.
Needs score
13:-1: ReferenceError: cursor is not defined
13:-1: ReferenceError: cursor is not defined
13:-1: ReferenceError: cursor is not defined
Warning: <Unknown File>:13: ReferenceError: cursor is not defined

In Mu3 that is...

At least a var cursor = curScore.newCursor(); is needed
Then changing to cursor.Rewind(Cursor.RewindMode.SCORE_START); the error message changes to
14:-1: TypeError: Cannot read property 'SCORE_START' of undefined

Then changing that to cursor.rewind("Cursor.RewindMode.SCORE_START"); (lower case r, arg in quotes), and it seems to work?

In reply to by Jojo-Schmitz

Sorry for the previous example, I was going to upload a different file, then I changed it at the last moment and apparently forgot to test it.

By passing the argument as as string, I also don't get an error message, but it seems like I always get the cursor back to tick 0, even if I pass as input "RewindMode.SELECTION_START" or "RewindMode.SELECTION_END", or any other string.
For example, by running the attached plugin on the attached file, I get the following output:

Running…
Plugin Details:
  Menu Path: Plugins.TEST
  Version: 1.0.0
  Description: TEST.
  Requires Score
Debug: Current Tick: 960
Debug: Current Tick: 0
Debug: Current Tick: 0
Debug: Current Tick: 0
Debug: Current Tick: 0

This was with the following selection:

Selection.PNG

Apparently it rewinds to the beginnig of the score whatever string it receives in input. Could it be that rewinding to the beginning of the score is the default action of cursor.rewind(), if the input is invalid?

Attachment Size
PLUGIN_TEST_3.mscz 8.73 KB
TEST.qml 873 bytes

In reply to by Jojo-Schmitz

Out of curiosity I ported the test plugin to MS4, and got the same output. It would be nice if in this case cursor.Rewind() threw an exeption, or at least gave some indication that the given input is not valid.

As far as I understand, the plugin API for version 4 is not complete yet. Should this be reported somewhere?

Attachment Size
TEST.qml 1.12 KB

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