Converting .js to .qml newbie question
Hi,
I'm trying to convert the minor variations plugin to the new plugin format, but keeping as much of the original code in the .js script. Therefore in the top of my .qml file I have
import "minorvariations.js" as MinorVars;
The third line of "run" is
var c = new Cursor(curScore);
and I get the error TypeError: Type error
presumably because Cursor is undefined...I think, unless the Cursor type has changed since this plugin was written.
Is there some header file I need to include in the minorvariations.js file to correct this?
thanks
Samantha
Comments
I never created plugins for the old system, but the current syntax to get a cursor would be :
var c = curScore.newCursor();
Check the manual in the Plugin Creator if you find similar problems.
Hope it helps.
In reply to I never created plugins for by stevel05
Thanks. That worked! Now it gets stuck at mySelectedMeasureNumbers which I'm guessing is an undefined local function. Sigh!
I've reinstalled musescore, using a different method and now I have the documentation. Hopefully I can figure things out for myself now!
thanks
Samantha
Could you give some more details please? I'm on OSX 10.10 and trying to import a .js file into my plugin with no luck. I'm using the built in "Plugin Creator" and it keeps giving me the error "creating component failed". Are you using Plugin Creator , Xcode, loading the plugin via command line or some other environment for debugging?
Any info you could provide would be much appreciated!
In reply to Could you give some more by Damianos
Well, I don't think I can be much help. You couldn't call what I ended up doing "an environment". :)
l put lots of console.log(blah blah) in the code. I started musescore from the command line so I could see if those were printed out. Then everytime I wanted to run a new version of the plugin I had to close musescore and open it because it caches the plugins! That was the only way I could figure out to make it reload the new one!
It was very boring, but I got it to do what I wanted in the end.
If it's helpful, here's my rather messy and naive qml code...
The js and qml files are in the same directory. I don't think I had to set any paths anywhere for the js file to be found.
import QtQuick 2.0
import QtQuick.Controls 1.4
import MuseScore 1.0
import "minorvariations.js" as MinorVars;
MuseScore {
pluginType: "dialog"
width: 300
height: 200
menuPath: "Plugins.Minor Variations"
onRun: {
//MinorVars.run(curScore);
//Qt.quit()
}
ComboBox {
width: 300
height: 50
model: [ "Harmonic", "Melodic", "Un-Harmonic", "Un-Melodic" ]
id: changeChooser
}
Row{
anchors.centerIn: parent
spacing: parent.width/6
Rectangle {
id: okButton
//color: "grey"
width: 150; height: 75
y: 55
Text{
id: buttonLabel
anchors.centerIn: parent
text: "OK"
}
MouseArea{
id: buttonMouseArea
anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
//onClicked handles valid mouse button clicks
onClicked: { MinorVars.run(changeChooser.currentIndex); Qt.quit();}
}
}//rectangle
}//row
}
In reply to Well, I don't think I can be by chibi-muse
Thanks for the reply. By environment I meant editor. Are you using the "Plugin Creator" that is built into MuseScore? I ask because that's what I'm using and I am getting errors when my plugin tries to load in the javascript file.
In reply to Thanks for the reply. By by Damianos
Oh right! No, I just used the default text editor in Linux Mint. The plugin creator didn't seem to be all that useful, other than providing a bare bones reference to the API. It doesn't seem to help with debugging or syntax highlighting or give informative error messages, or any of the things you'd expect from an IDE. Not that it claims to be an IDE but, well, I didn't find it all that helpful. Perhaps I just don't understand it.