How to add horizontal frame by plugin?
Please, how is it possible, to add horizontal frame by plugin.
In source, it seems to be done https://github.com/musescore/MuseScore/blob/1bf03517546291f07f9c70ed2db…
but when I tried
onRun: { var cursor = curScore.newCursor(); cursor.rewind(Cursor.SCORE_START); cursor.track = 0; var sym = newElement(Element.HBOX); cursor.add(sym); Qt.quit() } }
it does nothing.
Thank You for help.
Comments
It does something for me, but perhaps not immediately obvious because it doesn't do what you'd expect (nor can I explain why).
But the frame is added to the end of the score seemingly regardless of the cursor position. And you need a layout trigger to see it (for example change between page view and single page view).
In reply to It does something for me,… by jeetee
Deleted
In reply to Glad to see ongoing… by scorster
This and the prior message of mine deleted as they did not pertain.
Sorry for any inconvenience.
scorster
In reply to BTW, this is related to a… by scorster
This topic is not related to your discussion, but is about a Plugin API command not performing the requested action; and behaving differently than what a quick glance at the code behind it indicates.
The plugin API code quite clearly shows that the current segment's measure is requested and the element is added to that; so the expected outcome of the plugin command should be identical to what happens if you as a user target that measure and add the element to it (ie have the frame be inserted before the current measure).
Instead the plugin API action to insert seems to perform an append instead for no obvious code reason.
This has nothing to do with the request for an additional command to insert after the target point of reference; which then in turn might or might not also be made possible via the Plugin API.
In reply to Glad to see ongoing… by scorster
I suspect it's meant to mirror the behavior of the append measures command, where appending to the end of the score is by far the most common - it's what you do every time you run out of measures or realize you are getting close to running out. But indeed, an append after selection would make sense too.
In reply to I suspect it's meant to… by Marc Sabatella
Marc, I don't think so. It tries to add box to selected measure, exactly, as it does with "staff type change" for example.
I think, problem is, that HBoxs parent shouldn't be a "measure", but a "system", and hbox should be added in front of selected measure.
In reply to I don't think so. It tries… by sammik
I was responding more to the (now deleted) comment that the append functionality doesn’t menu make sense for the menu command. I think it does, least for consistency with what appending measures means. But how to get the command working in a plugin isn’t something I have insight into. I would think executing the command via plugin would do exactly the same as executing via menu or shortcut. But it looks like you aren’t using the command here, and instead are trying to do it in a more low level way. I guess I’d recommend the command then ;-)
In reply to I was responding more to the… by Marc Sabatella
Ah, OK, I understand.
You are right, the possible answer for topic question is: use command "insert-hbox".
Another question is, if plugin api has a bug in this
cursor.add(hbox)
. I think, it does.