How to delete subtitle?
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
Select the subtitle and delete. It sould work.
In reply to Select the subtitle and… by Ruben Remus
I guess the OP wants to do that in a plugin
In reply to I guess the OP wants to do… by Jojo-Schmitz
Really?
In reply to Really? by Ruben Remus
I know, but I presume they (and the many other plugin creators) have a reason. Still...
In reply to I know, but I presume they … 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.
In reply to I know, but I presume they … by underquark
Yeah!, that little girl represents me. : )
In reply to Really? by Ruben Remus
Yes. Really. This is a forum for writing plugins after all :-)
In reply to Yes. Really. This is a forum… by paul.musescore
I hadn't realised when my first response, sorry.
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 There is no 'method'… by ILPEPITO
Very useful. Ta! I'll have a go at that.
Paul
In reply to There is no 'method'… 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
In reply to Thanks for this - I managed… by paul.musescore
The information is in a 'segment' object, the 'annotations' object.
If you find a 'chord' it will be:
chord.parent.annotations
Instead a 'rest':
rest.parent.annotations
This object can have multiple elements inside it:
var l = chord.parent.annotations.length
for (var i=0; i
In reply to The information is in a … by ILPEPITO
I forgot about the comment limitations...I attach the code in text format-
Also check that the object is not empty!
Hope this helps
In reply to I forgot about the comment… by ILPEPITO
Brilliant. That works. Thank you so much.
Paul