How to detect whether there is a selection in a QML based plugin
Î'm trying to get the same effect in 2.0 QML based plugins as we have for the pre 2.x ones in
I think it is very usefull for almost any plugin to work on a selection, if there is one, and on the entire score otherwise.
Any idea how to get this to work?
So far I only know how to process either the entire score or a selection.
Comments
bump
No idea anybody?
Should this get turned into an enhancement request?
Something like having a read-only property 'bool selection' for curScore which tells whether there is or isn't something selected?
In reply to bumpNo idea anybody?Should by Jojo-Schmitz
It's possible. The function name in the new QML framework are not that user friendly though. Here is a working color note to selection plugin in MuseScore f80dfa796c
In reply to It's possible. The function by [DELETED] 5
Ah! So testing "if (!cursor.segment)" and using "var endTick = cursor.tick // if no selection, end of score" is the trick here.
I'll have a play with that, thanks.
{Edit 1] Hmm, that colornotes plugin is not part of MuseScore yet, right? Mind to add/update it?
[Edit 2] Well, it does work on a selection, but I can't get it to work with nothing selected, nothing gets colored then
In reply to It's possible. The function by [DELETED] 5
I can't get your example to work.
Also this
endStaff = curScore.staves; // and end with last
needs to be
endStaff = curScore.nstaves; // and end with last
But that still doesn't make it work, not for the entire score at least, only for a selection.
Problem might be that we don't have a rewind to end of score.
In reply to I can't get your example to work by Jojo-Schmitz
gist updated to work on the full score as well.
In reply to gist updated to work on the by [DELETED] 5
Yep, that works, thanks.
Well, mostly. If you first run or agains a selection (which work) and than run it without a selection, it doesn't do anything. Actually it seems to remeber and work on the old selection again, which isn't a visible change, but gets apparent when undoing the previous change.
In reply to Yep, that works, by Jojo-Schmitz
That's probably an inner problem in the way the selection is managed in MuseScore. It seems to remove it from the screen but not internally. It's fixed in 3d55d907e8
In reply to That's probably an inner by [DELETED] 5
yes, that was my suspicion. Thanks for fixing it!
Now I think it is time to get your improved colornotes into the trunk to replace the current one, wouldn't you agree?
In reply to yes, that was my suspicion. by Jojo-Schmitz
Part of pull request 204