How to delete subtitle?

• May 29, 2025 - 11:16

I must be mising something obvious! :-) I can add a subtitle to a score with score.addText("subtitle","something"). But if there is already a subtitle present, this adds new one in addition to the existing one. How do I delete any existing one so I can replace it?
Thanks
Paul


Comments

In reply to by underquark

I have a plugin which adds annotations to the score for instruments such as the harmonica which come in different keys. I wanted to add something to the score to emphasise which version of the instrument the score had been annotated for, so I was going to put that into the subtitle. If someone then chooses to re-annotate the score for a different instrument, I need to remove the previous subtitle and replace it with the new one.
Of course, the subtitle probably isn't technically the most appropriate place for this - I'd definitely welcome alternative suggestions - but it has to be somewhere visible and most importantly something that can be changed fairly easily by the plugin code - the plugin documentation isn't great, and I've been trying to avoid delving into the source code or using something undocumented which is likely to break in a future release.

There is no 'method' available for what you want to do without manually selecting the item in question. You could place the indication in a 'system text' in the first measure, with a rather large 'fontSize' and highlighted by a rectangular frame. This object is easily manipulated (you can create, erase, rewrite) and lends itself better to your purpose. Then, do as you want.

In reply to by ILPEPITO

Thanks for this - I managed to create the system text (by adding it to a cursor at the start of the score) - but once I've created it, I can't work out how to get a reference to it next time I run? I have a cursor which iterates over the score, but this only seems to return CHORDS and RESTS. (How) can I get a reference to it to update it ?
Thanks for the help
Paul

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