source/lib/VBMenu.js
// Note that the click event handlers execute in the Main Process context

Note that the click event handlers execute in the Main Process context
Note that the click event handlers execute in the Main Process context
static createContextMenu(connId, ip, port) {
    const config = g('vbConfig').config
    let mainWindow = g('mainWindow')
    let floatList = g('floatList')
    const menu = new Menu()
    let index = 0
    menu.append(new MenuItem({
      label: 'Log file ...',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('logFile', connId)
      }
    }))
    index++
    menu.append(new MenuItem({
      label: 'Resume logging',
      enabled: false,
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('logResume', connId)
      }
    }))
    VBMenu.RESUME_LOGGING = index++
    menu.append(new MenuItem({
      label: 'Pause logging',
      enabled: false,
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('logPause', connId)
      }
    }))
    VBMenu.PAUSE_LOGGING = index++
    menu.append(new MenuItem({type: 'separator'}))
    index++
    menu.append(new MenuItem({
      label: 'Re-connect',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('reConnect', connId)
      }
    }))
    index++
    menu.append(new MenuItem({
      label: 'Close tab',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('closeTab', connId)
      }
    }))
    index++
    menu.append(new MenuItem({
      label: 'Float tab',
      visible: true,
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('floatTab', connId)
      }
    }))
    VBMenu.FLOAT_TAB = index++
    menu.append(new MenuItem({
      label: 'Unfloat tab',
      visible: false,
      click(menuItem, browserWindow, event) {
        mainWindow.webContents.send('unFloatTab', ip, port)
        browserWindow.webContents.send('unFloatTab', connId)
      }
    }))
    VBMenu.UNFLOAT_TAB = index++
    menu.append(new MenuItem({type: 'separator'}))
    index++
    menu.append(new MenuItem({
      label: 'Auto scroll',
      type: 'checkbox',
      checked: config.autoScroll,
      click(menuItem, browserWindow, event) {
        const checked = menuItem.checked
        config.autoScroll = checked
        g('saveConfigObject')()
        VBMenu.setAppMenuSettings(checked, undefined)
        mainWindow.webContents.send('autoScrollChanged', checked)
        floatList.forEach(
          win => win.webContents.send('autoScrollChanged', checked)
        )
      }
    }))
    VBMenu.AUTO_SCROLL = index++
    menu.append(new MenuItem({
      label: 'Auto wrap',
      type: 'checkbox',
      checked: config.autoWrap,
      click(menuItem, browserWindow, event) {
        const checked = menuItem.checked
        config.autoWrap = checked
        g('saveConfigObject')()
        VBMenu.setAppMenuSettings(undefined, checked)
        mainWindow.webContents.send('autoWrapChanged', checked)
        floatList.forEach(
          win => win.webContents.send('autoWrapChanged', checked)
        )
      }
    }))
    VBMenu.AUTO_WRAP = index++
    menu.append(new MenuItem({type: 'separator'}))
    index++
    menu.append(new MenuItem({
      label: 'Clear screen',
      accelerator: 'Alt+C',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('clearScreen', connId)
      }
    }))
    index++
    menu.append(new MenuItem({
      label: 'Clear line',
      accelerator: 'Esc',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('clearLine', connId)
      }
    }))
    index++
    menu.append(new MenuItem({
      label: 'Cursor to Input',
      accelerator: 'Ctrl+I',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('focusInput', connId)
      }
    }))
    index++
    menu.append(new MenuItem({type: 'separator'}))
    index++
    menu.append(new MenuItem({
      label: 'Find (toggle)',
      accelerator: 'CmdOrCtrl+F',
      click(menuItem, browserWindow, event) {
        browserWindow.webContents.send('findInPage', connId)
      }
    }))
    index++
    return menu
  }
static createContextMenu ( connId , ip , port ) { const config = g ( 'vbConfig' ) . config let mainWindow = g ( 'mainWindow' ) let floatList = g ( 'floatList' ) const menu = new Menu ( ) let index = 0 menu . append ( new MenuItem ( { label : 'Log file ...' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'logFile' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { label : 'Resume logging' , enabled : false , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'logResume' , connId ) } } ) ) VBMenu . RESUME_LOGGING = index ++ menu . append ( new MenuItem ( { label : 'Pause logging' , enabled : false , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'logPause' , connId ) } } ) ) VBMenu . PAUSE_LOGGING = index ++ menu . append ( new MenuItem ( { type : 'separator' } ) ) index ++ menu . append ( new MenuItem ( { label : 'Re-connect' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'reConnect' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { label : 'Close tab' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'closeTab' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { label : 'Float tab' , visible : true , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'floatTab' , connId ) } } ) ) VBMenu . FLOAT_TAB = index ++ menu . append ( new MenuItem ( { label : 'Unfloat tab' , visible : false , click ( menuItem , browserWindow , event ) { mainWindow . webContents . send ( 'unFloatTab' , ip , port ) browserWindow . webContents . send ( 'unFloatTab' , connId ) } } ) ) VBMenu . UNFLOAT_TAB = index ++ menu . append ( new MenuItem ( { type : 'separator' } ) ) index ++ menu . append ( new MenuItem ( { label : 'Auto scroll' , type : 'checkbox' , checked : config . autoScroll , click ( menuItem , browserWindow , event ) { const checked = menuItem . checked config . autoScroll = checked g ( 'saveConfigObject' ) ( ) VBMenu . setAppMenuSettings ( checked , undefined ) mainWindow . webContents . send ( 'autoScrollChanged' , checked ) floatList . forEach ( win => win . webContents . send ( 'autoScrollChanged' , checked ) ) } } ) ) VBMenu . AUTO_SCROLL = index ++ menu . append ( new MenuItem ( { label : 'Auto wrap' , type : 'checkbox' , checked : config . autoWrap , click ( menuItem , browserWindow , event ) { const checked = menuItem . checked config . autoWrap = checked g ( 'saveConfigObject' ) ( ) VBMenu . setAppMenuSettings ( undefined , checked ) mainWindow . webContents . send ( 'autoWrapChanged' , checked ) floatList . forEach ( win => win . webContents . send ( 'autoWrapChanged' , checked ) ) } } ) ) VBMenu . AUTO_WRAP = index ++ menu . append ( new MenuItem ( { type : 'separator' } ) ) index ++ menu . append ( new MenuItem ( { label : 'Clear screen' , accelerator : 'Alt+C' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'clearScreen' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { label : 'Clear line' , accelerator : 'Esc' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'clearLine' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { label : 'Cursor to Input' , accelerator : 'Ctrl+I' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'focusInput' , connId ) } } ) ) index ++ menu . append ( new MenuItem ( { type : 'separator' } ) ) index ++ menu . append ( new MenuItem ( { label : 'Find (toggle)' , accelerator : 'CmdOrCtrl+F' , click ( menuItem , browserWindow , event ) { browserWindow . webContents . send ( 'findInPage' , connId ) } } ) ) index ++ return menu }
Note that the click event handlers execute in the Main Process context
Note that the click event handlers execute in the Main Process context
// Reference the global config object in the Main Process
 // Reference to main window in the Main Process
 // Reference the global webContentsList so we can send IPCs to all windows
 // Create a Menu remote object
 // Set visible to false if floating tab
 // Send IPC to renderer process (DockPanel), which will remove
 // the docked connection tab, and send an IPC to the Main Process
 // to create a new Floating connection window
 // Set visible to true if docked tab
 // Send IPC to DockPanel window so it can create new connection in dock
 // and remove the floating tab from its list
 // Send IPC to renderer of FloatPanel window so it can terminate
 // Update main process config object
 // Flush config to disk
 // Update main menu auto scroll flags (in main process)
 // Notify the renderer process of the change
 // Note: send IPC to main window NOT the window where the context
 // menu was invoked, otherwise if the context menu is invoked
 // from a floating window, the change will not get propagated
 // to the main dock
 // Update main process config object
 // Flush config to disk
 // Update main menu auto wrap flags (in main process)
 // Notify the renderer process of the change
 // Note: send IPC to main window NOT the window where the context
 // menu was invoked, otherwise if the context menu is invoked
 // from a floating window, the change will not get propagated
 // to the main dock
