use MouseEvent in keybind change hooks

This commit is contained in:
Dimava 2020-05-30 10:57:02 +03:00
parent e58c2fd371
commit 79dcd79734
2 changed files with 26 additions and 1 deletions

View File

@ -86,6 +86,16 @@ for (const categoryId in KEYMAPPINGS) {
*/
export function getStringForKeyCode(code) {
switch (code) {
case 0:
return "LMB";
case 1:
return "MMB";
case 2:
return "RMB";
case 3:
return "MB4";
case 4:
return "MB5";
case 8:
return "⌫";
case 9:

View File

@ -121,9 +121,24 @@ export class KeybindingsState extends TextualGameState {
this.updateKeybindings();
});
dialog.inputReciever.backButton.add(() => {});
const clickListener = event => {
console.log(event);
if (event.target.tagName == "BUTTON") {
return;
}
event.preventDefault();
const keyCode = event.button;
this.app.settings.updateKeybindingOverride(id, keyCode);
this.dialogs.closeDialog(dialog);
this.updateKeybindings();
};
dialog.inputReciever.backButton.add(() => {});
this.dialogs.internalShowDialog(dialog);
dialog.element.onmousedown = clickListener;
this.app.sound.playUiSound(SOUNDS.dialogOk);
}