Potential Bug: Staff Color cannot be changed with plugin

• Oct 9, 2022 - 22:29

I wrote a short script to change the color of each staff in a score to white. However, when I attempt to run the program, the color of any of the staves do not change. I have the program print out the staff color to the debug log after the attempt to change it to white (#FFFFFF) and the debug log returns back #000000 (black), indicating that nothing has changed. When I change the color of a part's staff manually through "Staff/Part Properties > Staff Line Color" and then check the debug menu of the program, the program still returns the original black color hex value (#000000). Below is the code for the plugin and its QML file in case someone wants to point out that I am doing something wrong.

import QtQuick 2.9
import MuseScore 3.0
 
MuseScore {
      menuPath: "Plugins.StaffColor"
      description: "Re-colors all staves"
      version: "1.0"
   onRun: {
      var nstaves = curScore.nstaves
      var cursor = curScore.newCursor()
      cursor.rewind(0)
            for(var i=0; i<nstaves-1; i++) {
                  cursor.staffIdx = i
                  console.log(cursor.element.staff.part.longName)
                  cursor.element.staff.color = "#ffffff"
                  console.log(cursor.element.staff.color)
            }        
      Qt.quit();
      }
}
Attachment Size
StaffColor.qml 585 bytes

Comments

In reply to by [DELETED] 30709869

> "How would I use the program you sent me to help with this?"
You wouldn't, it's a link to the source code of MuseScore itself. In particular that is the function within MuseScore I believe to be called when you try to assign a new color from within the plugin.

> "Also if I may ask, what is a no-op?"
A no-op is programmer slang for "No Operation"; meaning nothing happens. It dates back to an assembly instruction (NOP) that resulted in the processor doing nothing for that instruction time.
Since the internal MuseScore function linked above goes to a function in which there is no code (it is commented out), the function in effect does nothing.

So my conclusion is that it seems that changing the staff lines color via QML is a thing that is simply not implemented in the MuseScore code.

Side note: you're not attempting to set every staff to white, since your loop condition is "< nstaves-1" meaning you don't alter the last staff in the score.

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