remove staff text with plugin
Hello,
I have been searching the forum for the correct syntax to remove staff text.
This is how to find them:
for (var n = 0; n < segment.annotations.length; n++) { var annotation = segment.annotations[n] if (annotation.type === Element.STAFF_TEXT) { // check position of element. if x-pos. far off from tickm then ignore if ( annotation.textStyleType === TextStyleType.STAFF || annotation.textStyleType === TextStyleType.FINGERING) { if (Math.abs(annotation.pos.x) < 1.0) { console.log("=> ... HURRAY ... normal staff text found: (" + annotation.text + ") at segment:" + segment.tick + ", position:" + annotation.pos.x) } } } }
Can anybody help with the correct syntax to delete a text? I tried several combinations like for example:
cursor.segment.annotations[n].text.remove(segment.annotations[n])
(Where n comes from one of the staff texts found from above)
Whatever combination I try, the error I get is that "remove" is either undefined or (obviously) not a function.
For notes the syntax is given here: https://musescore.org/en/node/81581 or here: https://musescore.org/en/node/81491
Can someone confirm that the answer is provided here: https://musescore.org/en/node/267604 (...In libmscore/segment.h, we could expose the function removeAnnotation(Element* e) ...Sure not for any 2.x version as there won't be further updates, so if any, then for 3.0..)
Reason for this question is that currently the Fix Fingering plugin does not handle staff fingering text and I am trying to implement functionality that staff fingering text is automatically converted to note.elements (Element.FINGERING) text.
Many thanks in advance for any help.
Marc Nijdam
Comments
removeElement(stafftext);
seems to work for me in MS3
where
var annotation = segment.annotations[aCount];
var stafftext = annotation;
In reply to removeElement(stafftext);… by elsewhere
4 years later and I was looking for this too.
I can confirm that your code still works with MS3.7 😀