Plugins that apply to selection
Hi, I've been trying out some existing plug-ins to see how they apply behaviour only to selected notes - and the ones I've checked don't actually work properly, they apply their changes to all the elements between the first and last selected elements! (I tried ColorNotes and another one that removed courtesy accidentals).
As far as I can see curScore.selection.elements
is the correct enumeration of all selected elements so is there a reason such plugins don't use this?
Actually my plugin will need to add/remove from this enumeration, which I thought would need curScore.selection.elements.remove or similar, but no luck with that so far.
It seems none of the sample qml files reference selection.elements at all.
Comments
Ok, I managed to get it working using:
But...it doesn't actually work if what's selected is a range! So how can I convert a range selection into a "individual notes" selection? Guess I have to do a clear and re-add?
In reply to Ok, I managed to get it… by Dylan Nicholson1
Hah, finally got it:
It was the "true" parameter for
select
I was missing.In reply to Hah, finally got it: … by Dylan Nicholson1
Any hints on how I could allow prompting the user to provide a pitch value (I want the 60 above to be configurable)? I've looked at some plugins that have configuration dialogs but haven't seen any for selecting a pitch.
Also can't see what function to use to shift notes to display on the staff above or below (ctrl+shift+up/down).
In reply to Any hints on how I could… by Dylan Nicholson1
Solved the latter issue -
cmd("move-up")
andcmd("move-down")
In reply to Solved the latter issue -… by Dylan Nicholson1
For now I just a very rudimentary dialog prompting for the pitch to split below:
As for the "why aren't other plugins using
selection.elements
" the answer is as plain and simple as: these plugins all predate this fairly recently added property.In reply to As for the "why aren't other… by jeetee
Is it worth putting up a PR with a fix to the sample ColorNotes.qml plugin to use it at least?
In reply to Is it worth putting up a PR… by Dylan Nicholson1
Sure, why not?
In reply to Sure, why not? by Jojo-Schmitz
I have it ready to go but it does behave slightly differently from the original as it leaves all notes selected if you start with nothing selected (the first thing it issues is
cmd("select-all")
in that case)...but nvm, fixed now, just issuescmd("escape")
after doing it in that case now.Is it necessary to create an issue/bug to link this against first?
In reply to I have it ready to go but it… by Dylan Nicholson1
I threw one up anyway...
https://github.com/musescore/MuseScore/pull/8141
In reply to As for the "why aren't other… by jeetee
@jeetee: do you remember or know when this
selection.elements
got added?In reply to @jeetee: do you remember or… by Jojo-Schmitz
My mind thought 3.5, but apparently that's only when plugins became enabled to change selection. (#293017: QML api: "Select an element" needed so plugins can search)
The
selection.elements
property seems to be introduced in 3.3 with this commitIn reply to My mind thought 3.5, but… by jeetee
Thanks!
Great job on this, BTW!