Hi all,
In my app I have a requirement to update a
StaveNote that has already been rendered - specifically, I want to be able to respell accidentals. Currently I am doing this by first removing the associated element from the DOM (I am using the SVG backend), then creating a new
StaveNote with certain properties copied from the old one (since I am respelling the accidentals, the new note's
keys,
keyProps and
modifiers arrays will have different contents). Finally I set the new note to the position in the
tickables array occupied by the old note, and call its
preFormat() and
draw() methods.
My code sets the id, voice, stave, clef, duration, render context and tickContext for the new note. This works, bit it's a rather cumbersome process. I can't see another way to do it, however, since the new note needs to retain all of this information (and also formatting information, which
preFormat() and
draw() seem to take care of) from the old note.
Is there a better way to achieve what I want? Perhaps simply modify the original note in place? Or simply do a shallow copy by iterating over and copying the contents of
all the original note's properties?
C