From 87933edb963cf548fb0ee425c1659504eed448e8 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Fri, 5 Oct 2018 10:02:03 +0100 Subject: [PATCH] fixed context menu and xterm mouse events (fixes #442) --- app/lib/window.ts | 4 ---- terminus-core/src/services/electron.service.ts | 4 +++- terminus-core/src/services/hostApp.service.ts | 2 +- terminus-terminal/src/frontends/xtermFrontend.ts | 4 ++++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/lib/window.ts b/app/lib/window.ts index 9f1a0185..540d056a 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -188,10 +188,6 @@ export class Window { ipcMain.on('window-set-title', (_event, title) => { this.window.setTitle(title) }) - - ipcMain.on('window-popup-context-menu', (_event, menuDefinition) => { - Menu.buildFromTemplate(menuDefinition).popup({ window: this.window }) - }) } private destroy () { diff --git a/terminus-core/src/services/electron.service.ts b/terminus-core/src/services/electron.service.ts index d20e3bcc..51237a12 100644 --- a/terminus-core/src/services/electron.service.ts +++ b/terminus-core/src/services/electron.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { TouchBar, BrowserWindow } from 'electron' +import { TouchBar, BrowserWindow, Menu } from 'electron' @Injectable() export class ElectronService { @@ -14,6 +14,7 @@ export class ElectronService { remote: any TouchBar: typeof TouchBar BrowserWindow: typeof BrowserWindow + Menu: typeof Menu private electron: any constructor () { @@ -29,6 +30,7 @@ export class ElectronService { this.nativeImage = this.remote.nativeImage this.TouchBar = this.remote.TouchBar this.BrowserWindow = this.remote.BrowserWindow + this.Menu = this.remote.Menu } remoteRequire (name: string): any { diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 9a3a6cfa..a64d2d78 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -169,7 +169,7 @@ export class HostAppService { } popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]) { - this.electron.ipcRenderer.send('window-popup-context-menu', menuDefinition) + this.electron.Menu.buildFromTemplate(menuDefinition).popup({}) } broadcastConfigChange () { diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index f05cfac6..ab4aa042 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -43,6 +43,10 @@ export class XTermFrontend extends Frontend { host.addEventListener('dragOver', (event: any) => this.dragOver.next(event)) host.addEventListener('drop', event => this.drop.next(event)) + + host.addEventListener('mousedown', event => this.mouseEvent.next(event)) + host.addEventListener('mouseup', event => this.mouseEvent.next(event)) + host.addEventListener('mousewheel', event => this.mouseEvent.next(event)) } detach (host: HTMLElement): void {