issue-2-scriptAccounts #4
37
app/main.ts
37
app/main.ts
@ -1,4 +1,4 @@
|
||||
import {app, BrowserWindow, screen} from 'electron';
|
||||
import {app, BrowserWindow, screen, Menu, ipcMain} from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
@ -50,6 +50,41 @@ function createWindow(): BrowserWindow {
|
||||
win = null;
|
||||
});
|
||||
|
||||
const contextMenuTemplate = [
|
||||
{
|
||||
label: 'New',
|
||||
submenu: [
|
||||
{
|
||||
label: "Gamesystem",
|
||||
click: () => {
|
||||
win!.webContents.send('context-menu', "new-location");
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "ScriptAccount",
|
||||
click: () => {
|
||||
win!.webContents.send('context-menu', "new-scriptaccount");
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
label: 'Edit...'
|
||||
},
|
||||
{
|
||||
label: 'Delete...'
|
||||
}
|
||||
]
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate(contextMenuTemplate);
|
||||
|
||||
win.webContents.on('context-menu', (e, params) => {
|
||||
console.log("Electron: Context menu showing")
|
||||
contextMenu.popup({ window: win!, x: params.x, y: params.y });
|
||||
})
|
||||
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<mat-action-list>
|
||||
<mat-list-item class="scriptAccount-item" *ngFor="let scriptAccount of gameModel!.scriptAccounts"
|
||||
(dblclick)="onOpenScriptAccount(scriptAccount)">
|
||||
(dblclick)="onOpenScriptAccount(scriptAccount)" (contextmenu)="onContextMenu($event)">
|
||||
<mat-icon class="scriptAccount-icon">inventory_2</mat-icon>{{scriptAccount.componentName}}
|
||||
</mat-list-item>
|
||||
</mat-action-list>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {GameModel} from "../../game-model/GameModel";
|
||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||
import {ElectronService} from "../../core/services";
|
||||
|
||||
@Component({
|
||||
selector: 'app-script-account-overview',
|
||||
@ -11,6 +12,9 @@ export class ScriptAccountOverviewComponent {
|
||||
@Input("gameModel") gameModel: GameModel | undefined
|
||||
@Output("onOpenScriptAccount") openScriptAccountEmitter: EventEmitter<ScriptAccount> = new EventEmitter<ScriptAccount>();
|
||||
|
||||
constructor(private electronService: ElectronService) {
|
||||
}
|
||||
|
||||
onOpenScriptAccount(scriptAccount: ScriptAccount) {
|
||||
console.log("onOpenScriptAccount (overview)")
|
||||
this.openScriptAccountEmitter.emit(scriptAccount);
|
||||
@ -22,5 +26,12 @@ export class ScriptAccountOverviewComponent {
|
||||
return scriptAccount;
|
||||
}
|
||||
|
||||
onContextMenu(event: MouseEvent) {
|
||||
if(this.electronService.isElectron) {
|
||||
console.log("[DEBUG] [ScriptAccountOverviewComponent] App is executed in electron")
|
||||
|
||||
} else {
|
||||
console.log("[DEBUG] [ScriptAccountOverviewComponent] App is not executed in electron")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user