Identify if some element is of text nature

• Sep 22, 2024 - 12:37

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 typeof 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

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).

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