Open ZenithRogue opened 5 years ago
There are a number of different options from what I've worked out. Try replacing in your code
"text": {
"id": "supermath_Kwzz",
"defaultMessage": "+"
}
with
text: '+'
Or
text: formatMessage({
id: 'supermath_Kwzz',
default: '+',
description: 'Sum'
})
For this to work, you will also have to import the formatMessage
function by adding
const formatMessage = require('format-message');
Or use the following function like is done in the ev3 extension
_formatMenu (menu) {
const m = [];
for (let i = 0; i < menu.length; i++) {
const obj = {};
obj.text = menu[i];
obj.value = i.toString();
m.push(obj);
}
return m;
}
The menu declaration then becomes
menus: [{
supermath: this._formatMenu(['+', '-', '*', '/']),
}],
Thanks @NitroCipher! This is really neat. As a heads-up: the Scratch 3.0 extension specification is still in very active development and the way menus work may continue to change. Once our extension specification is a little more settled we will publish documentation.
/cc @cwillisf @kchadha
I am trying to write a Scratch 2.0 to Scratch 3.0 extension converter, but am confused by the lack of documentation surrounding the dropdown menus here.
Here is my 2.0 extension
And my 3.0 conversion
Is there something I am missing with the dropdowns? Everything else was working prior to this.