diff --git a/app/main.ts b/app/main.ts index 17c3f2a..ffbea7c 100644 --- a/app/main.ts +++ b/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; } diff --git a/src/app/side-overviews/script-account-overview/script-account-overview.component.html b/src/app/side-overviews/script-account-overview/script-account-overview.component.html index d35d531..c1b8260 100644 --- a/src/app/side-overviews/script-account-overview/script-account-overview.component.html +++ b/src/app/side-overviews/script-account-overview/script-account-overview.component.html @@ -1,6 +1,6 @@ + (dblclick)="onOpenScriptAccount(scriptAccount)" (contextmenu)="onContextMenu($event)"> inventory_2{{scriptAccount.componentName}} diff --git a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts index b5cea39..f6672ad 100644 --- a/src/app/side-overviews/script-account-overview/script-account-overview.component.ts +++ b/src/app/side-overviews/script-account-overview/script-account-overview.component.ts @@ -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 = new EventEmitter(); + 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") + } + } }