vexflow
vexflow copied to clipboard
Bug: Key signatures don't update with Stave Clef changes
I'm trying to make a simple selector for a user to set the Clef and Key, but I'm noticing I get the same results with both clefs, that the key isn't considering the set clef.
url: https://music-helper.netlify.com code: https://github.com/mix3d/music-helper
I'm listening for changes in the dropdown, then calling setClef() or setKeySignature() on the staff, and then context.clear(); and stave.draw();
If I set the keySignature again after setting the clef, it draws correctly, so this is an order of operations issue (but no API docs sooo... #530 ). I would expect the Staff to update the keySignature correctly when it's Clef changes.
Example:

I've tried simulating what the Stave would do internally on clef change, (calling keySignatures[0].setKeySig), but this did not have the desired effect, even though calling stave.setKeySignature(keySelector.value) DID work.
// --- on clef change:
stave.setClef(clefSelector.value);
// because of issue #728, I have to do this manually
const keySignatures = stave.getModifiers();
keySignatures
.filter(key => key.category === KeySignature.CATEGORY)
.forEach(key => {
key.setKeySig(keySelector.value)
// also tried key.format() here
})
I also tried editing the source setClef code, attempting to update the keysigs, but it does not seem to be working for me either.
const keySignatures = this.getModifiers(position, KeySignature.CATEGORY);
keySignatures.forEach(key => key.format())
@mix3d is this still an issue or was it closed with the feature above?
@0xfe do you know if this is still an issue?
@mix3d is this still an issue or was it closed with the feature above?
I'll try to get my project running this weekend and try again. I lost steam when the library wasn't as out-of-the-box as I'd hoped, and now that I'm taking a hiatus from my choir due to covid, I have even less pressure to make my project happen.
@mix3d What is the name of your project?