deselect(element) doesn't work, if selection is range

• Mar 31, 2021 - 12:13

If I select range in score (not by plugin), I can deselcet some of elements. (It also changed range selection to list selection).

It is not possible to do this in plugin. If I deselect element of range selection, it removes all selection.

Is it possible to go around this somehow?
I can imagine, I can loop elements and create new selection, but this way "only a limited number of element types is supported".


Comments

I'm not the world's greatest plugin expert; but from my experience so far I don't believe you can deselect inside a plugin the way you wish to. Unless, perhaps, you could do some trickery using the 'cmd()' commands? Meaning you'd be simulating a user at the keyboard from inside your plugin.

The bigger question might be: what would you then intend to do with the remaining selected items? What are you trying to achieve in the end?

In reply to by sammik

I think maybe you're looking at this wrong. You can't copy list selections even from the GUI - well, at least not arbitrary ones. For instance, what would it mean to copy just one note of a chord from beat two of a measure, plus a hairpin on another staff, plus the composer text from the title frame? We only allow copying of very specific list selections - a list of lyrics, or of articulations, etc.

Meaning, even if you successfully created the selection, it would be usefuless for anything else deleting or making invisible. What you want instead is the Selection Filter - this is how you exclude elements from the selection while keeping it a range so you can do range things with it.

As for the specific feature of converting a range to a list by adding or removing individual elements - this was not something the UI could do either until quite recently, I think I added it maybe around 3.4 or 3.5. It's a bit of a hack actually, and I have no idea how one would go extending the plugin framework to produce the same. but you could possibly reproduce it in roughly the same way yourself - create a list of the selected elements, clear the selection, then build a new one by adding the elements back one by one. Again, though, it wouldn't actually be very useful, so probably not worth the bother. Copy and delete would be more straightforward, if you can't access the Selection Filter.

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