Update display float key handlers
This commit is contained in:
parent
a9c4ce724c
commit
b7144ed879
@ -56,15 +56,14 @@ class DisplayFloat extends Display {
|
|||||||
|
|
||||||
onKeyDown(e) {
|
onKeyDown(e) {
|
||||||
const key = Display.getKeyFromEvent(e);
|
const key = Display.getKeyFromEvent(e);
|
||||||
const handlers = DisplayFloat.onKeyDownHandlers;
|
const handler = DisplayFloat._onKeyDownHandlers.get(key);
|
||||||
if (hasOwn(handlers, key)) {
|
if (typeof handler === 'function') {
|
||||||
const handler = handlers[key];
|
|
||||||
if (handler(this, e)) {
|
if (handler(this, e)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onKeyDown(e);
|
return super.onKeyDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOptionsContext() {
|
getOptionsContext() {
|
||||||
@ -96,15 +95,15 @@ class DisplayFloat extends Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayFloat.onKeyDownHandlers = {
|
DisplayFloat._onKeyDownHandlers = new Map([
|
||||||
'C': (self, e) => {
|
['C', (self, e) => {
|
||||||
if (e.ctrlKey && !window.getSelection().toString()) {
|
if (e.ctrlKey && !window.getSelection().toString()) {
|
||||||
self.onSelectionCopy();
|
self.onSelectionCopy();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}]
|
||||||
};
|
]);
|
||||||
|
|
||||||
DisplayFloat._messageHandlers = new Map([
|
DisplayFloat._messageHandlers = new Map([
|
||||||
['setContent', (self, {type, details}) => self.setContent(type, details)],
|
['setContent', (self, {type, details}) => self.setContent(type, details)],
|
||||||
|
Loading…
Reference in New Issue
Block a user