Skip to content

Conversation

@parisk
Copy link
Contributor

@parisk parisk commented Nov 4, 2016

Made right-click work on all browsers.

The issue with the previous implementation was that it was bound to the contextmenu DOM event.

While this works for Chrome and Safari (and Edge?), Firefox and Internet Explorer fire the contextmenu event after the menu appears (thus highjacking the textarea position is pointless). So, I moved on and detected right-click using the mousedown DOM event on Firefox and MSIE.

In addition, I moved all browser detecting utilities into a new utils/Browser.js module.

I would like to add some tests for this module but I couldn't find a way to make it work with Mocha, since navigator is absent.

Closes #310

@parisk parisk added this to the 2.1.0 milestone Nov 4, 2016
@parisk parisk self-assigned this Nov 4, 2016
* @module xterm/utils/Generic
*/

export let contains = function(el, arr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arr, el would be more intuitive ordering imo "does arr contain el"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 changing

*/

export let contains = function(el, arr) {
for (var i = 0; i < arr.length; i += 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return arr.indexOf(el) >= 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 changing

src/xterm.js Outdated
});
}

if (isFirefox || isMSIE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a concern you're forking the logic here? If both work equally well with mousedown maybe that would be better so all browsers use the same code path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it doesn't work on Chrome with mousedown. The "Paste" option is disabled.

term.textarea.style.height = '10px';
term.textarea.style.left = x + 'px';
term.textarea.style.top = y + 'px';
term.textarea.style.width = '20px';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this is bigger all of a sudden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just gave it a little bit of padding, because I think it could run into corner cases.

@parisk parisk changed the title Make right-click worn on all browsers Make right-click work on all browsers Nov 4, 2016
@parisk
Copy link
Contributor Author

parisk commented Nov 4, 2016

@Tyriar do you have any clue why this particular test might be failing?

@Tyriar
Copy link
Member

Tyriar commented Nov 4, 2016

@parisk probably related to platform.isMac. Try adding a few console.logs to the test should find the problem fairly easily.

@parisk
Copy link
Contributor Author

parisk commented Nov 4, 2016

Thanks @Tyriar, the error message wasn't that helpful 😅 . I was setting xterm.isMSWindows instead of the 🆕 xterm.browser.isMSWindows.

@parisk
Copy link
Contributor Author

parisk commented Nov 4, 2016

@Tyriar tests are passing, feel free to take another look, when it's 🆗 for you.

@parisk parisk merged commit 9ab0455 into master Nov 4, 2016
@parisk parisk mentioned this pull request Nov 4, 2016
@Tyriar Tyriar deleted the issue-#310-cross-browser-right-click branch November 4, 2016 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants