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

Add option to define a selection of MouseButtons to ignore #216

Merged
merged 4 commits into from
Dec 9, 2023

Conversation

Pietrrrek
Copy link
Contributor

Replaces #214

@simonwep
Copy link
Owner

Thank you very much, what do you think of swapping the option into explicitly listing buttons via mouseButtons that can be used? I would say by default you only want to enable the primary button.

@Pietrrrek
Copy link
Contributor Author

Pietrrrek commented Nov 13, 2023

That is probably the more correct approach considering the approach that is taken in the rest of the config (enabling over disabling).

The current implementation ensures backwards compatibility. Consumers of this package may safely update the dependency without having to tweak existing code, I'd say that the decision is up to you given that you're the main maintainer :^)

I'd gladly contribute such a change if you decide to go for it, I could also add support for modifier buttons (such that e.g. only CTRL + LMB triggers selection)

@simonwep
Copy link
Owner

The current implementation ensures backwards compatibility. Consumers of this package may safely update the dependency without having to tweak existing code, I'd say that the decision is up to you given that you're the main maintainer :^)

Yeah, I didn't really follow semver considering this is one of my oldest projects. I'd actually take the breaking change in exchange for a cleaner config and add a note in the release notes.

I'd gladly contribute such a change if you decide to go for it, I could also add support for modifier buttons (such that e.g. only CTRL + LMB triggers selection)

That'd be awesome, not sure how I'd represent these combination in the config though - this can quickly get complicated if you, for example, only want to have to press CTRL if you're using the second button. I think, for now, having a positive mouseButtons config,

This commit makes it possible for consumers of this package to define
more complex inputs that trigger the selection;
    e.g. Control + Shift + Left-mouse-button

A mouse-button is always required while the modifiers are optional.
@Pietrrrek
Copy link
Contributor Author

Pietrrrek commented Nov 14, 2023

Take a look at how I've structured the config and let me know if you'd like any changes. It might also be a good idea to use strings (primary | auxiliary | secondary ...) instead of the numbers from MouseEvent.button (0 | 1 | 2 ... , respectively).

Edit; on second thought, I'm really now sure whether strings would be better as that may give the impression that the library provides it's own definitions of mouse buttons and that it maps it to the space of MouseEvent.button, which of course is not the case (and probably shouldn't be). The usage of strings would provide a thin layer of abstraction, but in this case it may be misleading - I think that using the numeric values forces the consumers of the library to understand the underlying data-model of the event, which is necessary anyways when working with events in JS.

@simonwep
Copy link
Owner

simonwep commented Dec 9, 2023

Thank you very much for your contribution, I'll release a new version soon with these changes :) Happy holidays!

@simonwep simonwep merged commit ff34f72 into simonwep:master Dec 9, 2023
1 check passed
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.

2 participants