Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider middle click config in window mousedown listener #366

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

Elentary
Copy link
Contributor

Fixes #363

The idea is to take into account mouse button click config in the way it is done in Terminal.ts

@@ -447,7 +447,19 @@ function startUpMainMenu(extensionManager: ExtensionManager, keybindingsManager:
});
}

function startUpWindowEvents(mainWebUi: MainWebUi): void {
function mapEventToMouseButtonActionKey(ev: MouseEvent): string {
Copy link
Contributor Author

@Elentary Elentary Jan 12, 2022

Choose a reason for hiding this comment

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

I have noticed this function to be already copy-pasted in Terminal.ts and TerminalAceViewer.ts.
I wish I could extract it's definition to one place and reuse if only you suggested the best place for it

Copy link
Owner

Choose a reason for hiding this comment

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

That is good practice, but this code base has a very limited lifespan.

@@ -457,7 +469,12 @@ function startUpWindowEvents(mainWebUi: MainWebUi): void {

window.document.addEventListener('mousedown', (ev: MouseEvent) => {
if (ev.which === 2) {
WebIpc.clipboardReadRequest();
const key = mapEventToMouseButtonActionKey(ev);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not need to check for null because it is guaranteed by the if above that exactly middle button is pressed

const key = mapEventToMouseButtonActionKey(ev);
const generalConfig = configDatabase.getGeneralConfig();
const action = <MouseButtonAction> generalConfig[key];
if (action === 'paste') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I also consider paste_selection here ?

Copy link
Owner

Choose a reason for hiding this comment

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

The middle mouse button bug only seems to affect Windows. paste_selection is only available on Linux.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was able to reproduce it on Linux (Ubuntu 20.04)

@sedwards2009
Copy link
Owner

Thanks for digging into this. I've been very busy over on the qt branch moving and updating everything, and haven't been giving the older version of Extraterm much attention. I welcome improvements, but this is on the code base which is soon to be obsolete (I hope). The newer Qt code base is actually much simpler and easier to follow.

I'll accept this and try out the nightly build. If that is ok then I can do another bug fix release on 0.59.

@sedwards2009 sedwards2009 merged commit 0dfa748 into sedwards2009:master Jan 13, 2022
sedwards2009 pushed a commit that referenced this pull request Jan 15, 2022
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.

Mouse Middle Button Click = Paste?
3 participants