Open MaxGeldner opened 3 years ago
Hello, have you solved this problem ?
I'm interested in this feature as well. It may be helpful to allow multiple buttons to be mapped to the same action – for example, allowing DragPanHandler to be driven by either of the left or middle mouse buttons:
map.dragRotate.enable({
activateWith: [0, 1] // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
});
Would a pull request for this feature addition be welcome?
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.