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

How to prevent selection right after a right-click #101

Closed
minorbug opened this issue Mar 28, 2021 · 8 comments
Closed

How to prevent selection right after a right-click #101

minorbug opened this issue Mar 28, 2021 · 8 comments
Labels
question Further information is requested

Comments

@minorbug
Copy link

I would like to prevent the selection from starting immediately following a right click (also control-click on Mac). I have a UI with contextual menus, and I do not want the selection to start after closing the menu.

I assume I would do something in beforestart, but I'm not surer where to begin.

@simonwep
Copy link
Owner

simonwep commented Mar 28, 2021

Examples?, if not then just return false in beforestart if you don't want the selection to, well, start. Please read the docs and at least try to implement something. A JSFiddle or something similar always helps and I could talk a direct look at what you've done so far!

@simonwep simonwep added the question Further information is requested label Mar 28, 2021
@thiagomagro
Copy link

thiagomagro commented Mar 31, 2021

I think the question is more related to the event.stopPropagation(). Is it possible to preventing the click from going through @simonwep ?

@jamesthomsondev
Copy link

@simonwep An easy way to recreate this issue (On Chrome) is to right click on a selectable area and select Inspect. Not sure how you'd get around this other than to limit the click event that triggers Selection to only left mouse clicks. Perhaps another option to add to the config, e.g. leftClickOnly: true

@simonwep
Copy link
Owner

Here is an example of how you could do that :)

@LouGhys
Copy link

LouGhys commented May 3, 2021

I'm doing this:

selectionArea.on('beforestart', beforeStartHandler)

const beforeStartHandler = ({ event }: SelectionEvent) => { return (event as MouseEvent).buttons !== 2; }

@abubelinha
Copy link

@simonwep your example links lead me to 404 error pages

AlbertMN added a commit to AlbertMN/selection that referenced this issue Apr 4, 2022
Based on @LouGhys's comment in simonwep#101 - figured more people could find this useful.
@AlbertMN
Copy link
Contributor

AlbertMN commented Apr 4, 2022

Created a PR (#163) to add @LouGhys's example in the "recipes" file.

@simonwep
Copy link
Owner

Closing this #163, thank you @AlbertMN!

bright0220 added a commit to bright0220/Simonwep-selection that referenced this issue Nov 22, 2022
Based on @LouGhys's comment in simonwep/selection#101 - figured more people could find this useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants