]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/xterm.js
Fix right-click for Firefox and IE
[mirror_xterm.js.git] / src / xterm.js
index ac570683ab81308945ec9ff5a9b4e0e5487729ac..e1840f2000f2a7fcfc71f72a3fe816716446017d 100644 (file)
@@ -35,6 +35,7 @@ import { CompositionHelper } from './CompositionHelper.js';
 import { EventEmitter } from './EventEmitter.js';
 import { Viewport } from './Viewport.js';
 import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboard.js';
+import { isFirefox, isMSIE } from './utils/Browser';
 
 /**
  * Terminal Emulation References:
@@ -446,9 +447,21 @@ Terminal.prototype.initGlobal = function() {
   on(this.textarea, 'paste', function (ev) {
     pasteHandler.call(this, ev, term);
   });
-  on(this.element, 'contextmenu', function (ev) {
+
+
+  function rightClickHandlerWrapper (ev) {
     rightClickHandler.call(this, ev, term);
-  });
+  }
+
+  if (isFirefox || isMSIE) {
+    on(this.element, 'mousedown', function (ev) {
+      if (ev.button == 2) {
+        rightClickHandlerWrapper(ev);
+      }
+    });
+  } else {
+    on(this.element, 'contextmenu', rightClickHandlerWrapper);
+  }
 };
 
 /**
@@ -523,11 +536,6 @@ Terminal.prototype.open = function(parent) {
   this.document = this.parent.ownerDocument;
   this.body = this.document.getElementsByTagName('body')[0];
 
-  // Parse User-Agent
-  if (this.context.navigator && this.context.navigator.userAgent) {
-    this.isMSIE = !!~this.context.navigator.userAgent.indexOf('MSIE');
-  }
-
   // Find the users platform. We use this to interpret the meta key
   // and ISO third level shifts.
   // http://stackoverflow.com/q/19877924/577598
@@ -843,7 +851,7 @@ Terminal.prototype.bindMouse = function() {
           ? ev.which - 1
         : null;
 
-        if (self.isMSIE) {
+        if (isMSIE) {
           button = button === 1 ? 0 : button === 4 ? 1 : button;
         }
         break;