Hi,
Have you any console errors ? Maybe it's the if(theme == theme_2)
I tryed that and I haved and all worked fine :
Blockly.Themes.whitebg = Blockly.Theme.defineTheme('whitebg', {
'base': Blockly.Themes.Classic,
'componentStyles': {
'workspaceBackgroundColour': '#fff',
'toolboxBackgroundColour': '#222f3e',
'flyoutBackgroundColour': '#264653',
'scrollbarOpacity': 0.3,
}
});
Blockly.Themes.blackbg = Blockly.Theme.defineTheme('blackbg', {
'base': Blockly.Themes.Classic,
'componentStyles': {
'workspaceBackgroundColour': '#000',
'toolboxBackgroundColour': '#222f3e',
'flyoutBackgroundColour': '#264653',
'scrollbarOpacity': 0.3,
}
});
var theme = Blockly.Themes.whitebg;
function toogle_wk(){
if(theme == Blockly.Themes.whitebg){
console.log("Set black");
theme = Blockly.Themes.blackbg;
worklol.setTheme(Blockly.Themes.blackbg);
} else {
console.log("Set white");
theme = Blockly.Themes.whitebg;
worklol.setTheme(Blockly.Themes.whitebg);
}
}
var worklol = Blockly.inject('blocklyDiv', {
toolbox: document.getElementById('toolbox-categories'),
renderer: 'zelos',
theme: Blockly.Themes.whitebg,
});