Add shortcut to toggle color coding button
Press 'C' repeatedly to switch between the various color coding options. When the last one is reached, we show the regular route again.
This commit is contained in:
parent
d6c648d3eb
commit
8e78c858c1
2 changed files with 12 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
BR.RoutingPathQuality = L.Control.extend({
|
||||
options: {
|
||||
shortcut: {
|
||||
toggle: 67, // char code for 'c'
|
||||
muteKeyCode: 77 // char code for 'm'
|
||||
}
|
||||
},
|
||||
|
|
@ -140,7 +141,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
});
|
||||
}
|
||||
|
||||
if (this.options.shortcut.muteKeyCode) {
|
||||
if (this.options.shortcut.muteKeyCode || this.options.shortcut.toggle) {
|
||||
L.DomEvent.addListener(document, 'keydown', this._keydownListener, this);
|
||||
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
|
||||
}
|
||||
|
|
@ -192,10 +193,16 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
},
|
||||
|
||||
_keydownListener: function(e) {
|
||||
if (BR.Util.keyboardShortcutsAllowed(e) && this._active && e.keyCode === this.options.shortcut.muteKeyCode) {
|
||||
if (!BR.Util.keyboardShortcutsAllowed(e)) {
|
||||
return;
|
||||
}
|
||||
if (this._active && e.keyCode === this.options.shortcut.muteKeyCode) {
|
||||
this._muted = true;
|
||||
this._deactivate(this.routingPathButton);
|
||||
}
|
||||
if (!this._muted && e.keyCode === this.options.shortcut.toggle) {
|
||||
this.routingPathButton.button.click();
|
||||
}
|
||||
},
|
||||
|
||||
_keyupListener: function(e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue