Add support for history navigation using mouse buttons in the popup window (#707)

This commit is contained in:
toasted-nutbread 2020-08-02 19:00:36 -04:00 committed by GitHub
parent 1184320e3e
commit a81d69d6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,6 +49,9 @@ class DisplayFloat extends Display {
['setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}] ['setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}]
]); ]);
window.addEventListener('message', this._onWindowMessage.bind(this), false); window.addEventListener('message', this._onWindowMessage.bind(this), false);
document.documentElement.addEventListener('mouseup', this._onMouseUp.bind(this), false);
document.documentElement.addEventListener('click', this._onClick.bind(this), false);
document.documentElement.addEventListener('auxclick', this._onClick.bind(this), false);
this.initializeState(); this.initializeState();
@ -138,6 +141,38 @@ class DisplayFloat extends Display {
// Private // Private
_onMouseUp(e) {
switch (e.button) {
case 3: // Back
if (this._history.hasPrevious()) {
e.preventDefault();
}
break;
case 4: // Forward
if (this._history.hasNext()) {
e.preventDefault();
}
break;
}
}
_onClick(e) {
switch (e.button) {
case 3: // Back
if (this._history.hasPrevious()) {
e.preventDefault();
this._history.back();
}
break;
case 4: // Forward
if (this._history.hasNext()) {
e.preventDefault();
this._history.forward();
}
break;
}
}
_copySelection() { _copySelection() {
if (window.getSelection().toString()) { return false; } if (window.getSelection().toString()) { return false; }
this._invoke('copySelection'); this._invoke('copySelection');