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

Event Filtering #169

Open
alanOracle opened this issue Jan 14, 2024 · 0 comments
Open

Event Filtering #169

alanOracle opened this issue Jan 14, 2024 · 0 comments

Comments

@alanOracle
Copy link

There are some times I want to prevent terra draw from receive certain event.

One of the uses of this is when i display a property editor in the map(basically to change the color or style of a single feature), and because this container is above the map the click events related to that container are also being processed by terra draw, so the user ends up drawing below the editor without knowing because all the clicks he is doing while changing the style of something, so i would want to filter which events to be processed by terra draw.

This and many other scenarios pushed me to find a way to hack that.

The way Im doing it right now is registering a listener right before terra draw, then when one of these events is fired I check if I want to terra draw to receive the event and if I don't then i call stopImmediatePropagation and because my listener is being called before terra draw then that event doesnt get to terra draw.

The problem with this approach is, what if we implement something else that has to be registered after terra draw in the queue of events, then this new listeners will also be prevented from getting some events.

Since Im filtering various types of events it would make sense to have a different filter for each type of event terra draw uses.

The proposal is to pass an object of (event)=>boolean functions to terra draw that will serve as filters they will basically return if the event should be processed by terra draw or not.

One for each type of event you want to filter, I know these are the events being used by terra draw: "pointerdown" , "pointermove" , "contextmenu" , "pointerup" ,"keyup" ,"keydown".

Thanks hope this makes sense for more people to use.

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

No branches or pull requests

1 participant