Using score.addText (...) and cursor.add (textElement)

• Feb 12, 2016 - 00:49

I need to add some additional information text to the Score. I have found two ways - addText () and cursor.add (textElement)

1. In PluginCreator manual Score::addText () function is not documented but...
We can use addText (str_type, str_text) to add "subtitle",
   score.addText ("subtitle", "* text-text *")
"title" or some other text of type "str_type"
but if we add, say, subtitle, text will be added on top of the original subtitle whicn is read-only.
Q1. What the use of such operation? Can I somehow modify subtitle from the plugin?

2. Ok, I can
   score.addText ("my text", "* text-text *")
and "* text-text *" will be attached to the title frame (see image).
I also can create TEXT or STAFF_TEXT Element and attach it to some cursor position in the score (for example to first/last bar).
   cursor.add(textElement);
But then I need to manipulate this text in plugin program. So as far as I understand I should
- in first case - find Title frame and attached text Element and identify it as "my text"
- in second case - also find my text Element
I know how to iterate through score segments and elements but
Q2.Can anybody explain me, please, how can I find and identify exactly those text Element which contains my text?

Q3. Or may be there is better way to manipulate with addition info text of the score?

Attachment Size
MS_addText.JPG 44.37 KB

Comments

There is probably a good reason why addText is not documented... According to https://github.com/musescore/MuseScore/blob/2.0.2/libmscore/score.cpp#L… It will add a vertical frame as the beginning of the score, except if one exist. Then it will add a text in this vertical frame and style it with Title or Subtitle style depending on the first argument. This argument is ignored if it's not Title or Subtitle.

That's being said, if you explain *exactly* what you want to do, maybe we can find a way to do it with the plugin framework or implement it for a future version. So what "additional information" do you want to add? You want to add it where? Is this information linked to the page or to a given position in the music? How would you add this information manually in the score?

In reply to by [DELETED] 5

Thank you, Nicolas.
Yes I should give you an example. Plugin produce some special tuning of the score and also have reset (detune) mode, so user should be informed in what state score is. That's why plugin should add some text after tuning and remove it after detuning. Please look at the picture:
- first example is original score or score after reset (detune)
- second - one of the variants how I'd prefer to add information text in accurate way (after the last line of the score is better)
- third - bad style of adding text :-)

Attachment Size
MS_addText1.JPG 216.56 KB

In reply to by [DELETED] 5

Extension of the previous questions.
Let's see at the "notenames" plugin. If we will call it again and again - at every call it will add new text element to every note. Is possible to write it more accurate?
   if (isMyTextAlreadySet ())
      updateMyText()
   else addMyText()

I generally write a little introduction of foreword describing my source and how errors in the source were dealt with and sometimes some more info.

I just add a vertical frame in front of the score, stretch it out to a page and add text (either by copy/paste from an editor--you'll need to manually set the line breaks--or by typing directly.

In reply to by azumbrunn

azumbrunn, no problem with manual operations. We discuss plugin programming - how to add text to specific place and - more important - how then to find it for updating.
Also adding/removing frame in front of the score is not good because every adding/removing changes page structure of the score.

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