mapbox / mapbox/mapbox-gl-js

Possability to change which buttons execute which handlers

Open
#10,132 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

Some applications may use default buttons of Mapbox for other purposes. For example, an application could have an action on clicking the left mouse button and dragging on the map. In MapBox's default, this would trigger a panning action (if DragPanHandler is enabled).
Another use case: An application could have a context menu when clicking on the map. To be sure, that the user doen't modify the map when clicking the right mouse button and accidentely dragging the mouse a bit, I would like to move the DragRotate's default buttons from the right mouse button to e.g. the middle mouse button.

Design

Maybe there could be options when instanitating the handlers or the map, that assign the buttons to the handlers. E.g.: You could modify that button x can start the handler y.
With that you could e.g. remap the DragRotateHandler from "Right Mouse Button + Drag" to "Middle Mouse Button + Drag", if you change the button value in the options for the respective handler.

Of course developers can create interferring mouse button actions with that (two handlers react to the same button). This must be handled in some way or must be up to the developer to resolve.

Mock-Up

Example for mapping mouse buttons to a handler.

map.dragRotate.enable({
    activateWith: <0/1/2/3/4>  // Button number from MouseEvent.button
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the DragPanHandler and DragRotateHandler entry points referenced in the issue, along with the map.dragRotate API. Determine how handler activation currently interprets MouseEvent.button and how options are exposed. Done means applications can configure a handler's activating mouse button, with the behavior for conflicting assignments defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.