Update Electron main menu when a toggle button is switched

This commit is contained in:
Miro Spönemann
2020-02-26 09:43:32 +01:00
parent f6a8dceabc
commit 69c7383da8
3 changed files with 30 additions and 3 deletions

View File

@@ -301,7 +301,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
});
registry.registerCommand(ArduinoCommands.TOGGLE_COMPILE_FOR_DEBUG, {
execute: () => this.editorMode.toggleCompileForDebug(),
execute: () => {
this.editorMode.toggleCompileForDebug();
this.editorMode.menuContentChanged.fire();
},
isToggled: () => this.editorMode.compileForDebug
});
@@ -416,7 +419,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
});
registry.registerCommand(ArduinoCommands.TOGGLE_ADVANCED_MODE, {
execute: () => this.editorMode.toggleProMode(),
execute: () => {
this.editorMode.toggleProMode();
this.editorMode.menuContentChanged.fire();
},
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'right',
isToggled: () => this.editorMode.proMode
});

View File

@@ -1,4 +1,5 @@
import { injectable } from 'inversify';
import { Emitter } from '@theia/core/lib/common/event';
import { ApplicationShell, FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser';
import { ArduinoShellLayoutRestorer } from './shell/arduino-shell-layout-restorer';
import { OutputWidget } from '@theia/output/lib/browser/output-widget';
@@ -7,6 +8,8 @@ import { EditorWidget } from '@theia/editor/lib/browser';
@injectable()
export class EditorMode implements FrontendApplicationContribution {
readonly menuContentChanged = new Emitter<void>();
protected app: FrontendApplication;
onStart(app: FrontendApplication): void {