Identify if some element is of text nature
Hi,
Is there a way to identify that an element is a text element ? (my goal is to write a plugin that applies some colour and frame formatting)
Now I'm testing the type
of the element with a list of known text types:
console.log("element "+i+" is " + element.userName());
if (element.type == Element.REHEARSAL_MARK ||
element.type == Element.HARMONY ||
element.type == Element.SYSTEM_TEXT ||
element.type == Element.STAFF_TEXT ||
...
Is there a more generic way to identify text elements ?
Comments
Have you tried TEXT?
Would seem to stick out like a sore thumb for testing ;)
...but who knows.
In reply to Have you tried TEXT? [inline… by worldwideweary
I would have been nice ;-)
But it isn't a general super type for all text elements.
I just tested. Texts such as lyricist, composer, ... match this type.
But texts such as staff text, system text, rehearsal marks, ... don't :-(
In reply to I would have been nice ;-)… by parkingb
Oh, that's too bad. The actual codebase uses a TextBase class, which works for practically everything text related, but it may not be in the plugin API "architecture"
Maybe you could test for the existence of one of the text properties that you require and only apply the formatting when you find it.
For one of my plugins I built a list of element types as I came across them but it's clearly not a definitive list:
property var rgbElem : [ 20, 11, 42, 19, 25, 32, 33, 34, 58, 6, 7 ] // RGB-able elements
(These are v3 values and I think they changed with v4 but the enumeration object is quite slow so I chose not to use it).
In reply to Maybe you could test for the… by yonah_ag
Thanks for the suggestion. I'm testing on the existent of the
frameType
property, and it is working fine.