Access to system clipboard ?

• Feb 19, 2022 - 14:38

I have a somewhat niche usecase for writing a musescore plugin (essentially being able to write actual scores and turn them into supercollider notation) where the output of the plugin is raw text that is meant to be copied into another document, rather than create another entirely new document.

From what I've been reading there is no access to the system clipboard either inbound or outbound via the API - can someone confirm this for me ? If that's indeed the case, I can work around it, but it would be nice to be able to have this functionality so I didn't have to write some X11 glue code to move the data around.


Comments

There is no such special API in MuseScore but you can make use of features built into Qt Quick in your plugins. As follows from this StackOverflow answer, there is a somewhat hacky way to copy any text to the clipboard using an invisible TextEdit element. This way also works with MuseScore, and the following plugin indeed copies a text to the clipboard when I run it:

import QtQuick 2.0
import MuseScore 3.0
 
MuseScore {
      menuPath: "Plugins.Copy something to clipboard"
      description: ""
      version: "1.0"
 
      TextEdit {
            id: textEdit
            visible: false 
      }
 
      onRun: {
            textEdit.text = "something";
            textEdit.selectAll();
            textEdit.copy();
      }
}

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