fixed context menu and xterm mouse events (fixes #442)

This commit is contained in:
Eugene Pankov 2018-10-05 10:02:03 +01:00
parent a931d47c23
commit 87933edb96
4 changed files with 8 additions and 6 deletions

View File

@ -188,10 +188,6 @@ export class Window {
ipcMain.on('window-set-title', (_event, title) => { ipcMain.on('window-set-title', (_event, title) => {
this.window.setTitle(title) this.window.setTitle(title)
}) })
ipcMain.on('window-popup-context-menu', (_event, menuDefinition) => {
Menu.buildFromTemplate(menuDefinition).popup({ window: this.window })
})
} }
private destroy () { private destroy () {

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { TouchBar, BrowserWindow } from 'electron' import { TouchBar, BrowserWindow, Menu } from 'electron'
@Injectable() @Injectable()
export class ElectronService { export class ElectronService {
@ -14,6 +14,7 @@ export class ElectronService {
remote: any remote: any
TouchBar: typeof TouchBar TouchBar: typeof TouchBar
BrowserWindow: typeof BrowserWindow BrowserWindow: typeof BrowserWindow
Menu: typeof Menu
private electron: any private electron: any
constructor () { constructor () {
@ -29,6 +30,7 @@ export class ElectronService {
this.nativeImage = this.remote.nativeImage this.nativeImage = this.remote.nativeImage
this.TouchBar = this.remote.TouchBar this.TouchBar = this.remote.TouchBar
this.BrowserWindow = this.remote.BrowserWindow this.BrowserWindow = this.remote.BrowserWindow
this.Menu = this.remote.Menu
} }
remoteRequire (name: string): any { remoteRequire (name: string): any {

View File

@ -169,7 +169,7 @@ export class HostAppService {
} }
popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]) { popupContextMenu (menuDefinition: Electron.MenuItemConstructorOptions[]) {
this.electron.ipcRenderer.send('window-popup-context-menu', menuDefinition) this.electron.Menu.buildFromTemplate(menuDefinition).popup({})
} }
broadcastConfigChange () { broadcastConfigChange () {

View File

@ -43,6 +43,10 @@ export class XTermFrontend extends Frontend {
host.addEventListener('dragOver', (event: any) => this.dragOver.next(event)) host.addEventListener('dragOver', (event: any) => this.dragOver.next(event))
host.addEventListener('drop', event => this.drop.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 { detach (host: HTMLElement): void {