How to detect whether there is a selection in a QML based plugin

• Jan 2, 2013 - 15:47

Î'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 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 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 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 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.

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