Add reset argument menu item (#1566)
This commit is contained in:
parent
2098d2faae
commit
8fe0e5fdf5
@ -227,6 +227,7 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
|
|
||||||
this._eventListeners.addEventListener(scopesButton, 'menuOpen', this._onScopesMenuOpen.bind(this));
|
this._eventListeners.addEventListener(scopesButton, 'menuOpen', this._onScopesMenuOpen.bind(this));
|
||||||
this._eventListeners.addEventListener(scopesButton, 'menuClose', this._onScopesMenuClose.bind(this));
|
this._eventListeners.addEventListener(scopesButton, 'menuClose', this._onScopesMenuClose.bind(this));
|
||||||
|
this._eventListeners.addEventListener(menuButton, 'menuOpen', this._onMenuOpen.bind(this), false);
|
||||||
this._eventListeners.addEventListener(menuButton, 'menuClose', this._onMenuClose.bind(this), false);
|
this._eventListeners.addEventListener(menuButton, 'menuClose', this._onMenuClose.bind(this), false);
|
||||||
this._eventListeners.addEventListener(this._actionSelect, 'change', this._onActionSelectChange.bind(this), false);
|
this._eventListeners.addEventListener(this._actionSelect, 'change', this._onActionSelectChange.bind(this), false);
|
||||||
this._eventListeners.on(this._inputField, 'change', this._onInputFieldChange.bind(this));
|
this._eventListeners.on(this._inputField, 'change', this._onInputFieldChange.bind(this));
|
||||||
@ -244,6 +245,18 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
|
_onMenuOpen(e) {
|
||||||
|
const {action} = this._data;
|
||||||
|
|
||||||
|
const {menu} = e.detail;
|
||||||
|
const resetArgument = menu.bodyNode.querySelector('.popup-menu-item[data-menu-action="resetArgument"]');
|
||||||
|
|
||||||
|
const details = this._parent.getActionDetails(action);
|
||||||
|
const argumentDetails = typeof details !== 'undefined' ? details.argument : void 0;
|
||||||
|
|
||||||
|
resetArgument.hidden = (typeof argumentDetails === 'undefined');
|
||||||
|
}
|
||||||
|
|
||||||
_onMenuClose(e) {
|
_onMenuClose(e) {
|
||||||
switch (e.detail.action) {
|
switch (e.detail.action) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
@ -255,6 +268,9 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
case 'resetInput':
|
case 'resetInput':
|
||||||
this._resetInput();
|
this._resetInput();
|
||||||
break;
|
break;
|
||||||
|
case 'resetArgument':
|
||||||
|
this._resetArgument();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,9 +322,6 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
newValue = `${DOMDataBinder.convertToNumber(value, node)}`;
|
newValue = `${DOMDataBinder.convertToNumber(value, node)}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (value !== newValue) {
|
|
||||||
this._setArgumentInputValue(node, newValue);
|
|
||||||
}
|
|
||||||
this._setArgument(newValue);
|
this._setArgument(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,6 +382,15 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
this._inputField.setInput(key, modifiers);
|
this._inputField.setInput(key, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _resetArgument() {
|
||||||
|
const {action} = this._data;
|
||||||
|
const details = this._parent.getActionDetails(action);
|
||||||
|
const argumentDetails = typeof details !== 'undefined' ? details.argument : void 0;
|
||||||
|
let argumentDefault = typeof argumentDetails !== 'undefined' ? argumentDetails.default : void 0;
|
||||||
|
if (typeof argumentDefault !== 'string') { argumentDefault = ''; }
|
||||||
|
await this._setArgument(argumentDefault);
|
||||||
|
}
|
||||||
|
|
||||||
_getDefaultKeyAndModifiers(defaultHotkeys, action) {
|
_getDefaultKeyAndModifiers(defaultHotkeys, action) {
|
||||||
for (const {action: action2, key, modifiers} of defaultHotkeys) {
|
for (const {action: action2, key, modifiers} of defaultHotkeys) {
|
||||||
if (action2 !== action) { continue; }
|
if (action2 !== action) { continue; }
|
||||||
@ -438,6 +460,12 @@ class KeyboardShortcutHotkeyEntry {
|
|||||||
|
|
||||||
async _setArgument(value) {
|
async _setArgument(value) {
|
||||||
this._data.argument = value;
|
this._data.argument = value;
|
||||||
|
|
||||||
|
const node = this._argumentInput;
|
||||||
|
if (node !== null && this._getArgumentInputValue(node) !== value) {
|
||||||
|
this._setArgumentInputValue(node, value);
|
||||||
|
}
|
||||||
|
|
||||||
await this._modifyProfileSettings([{
|
await this._modifyProfileSettings([{
|
||||||
action: 'set',
|
action: 'set',
|
||||||
path: `${this._basePath}.argument`,
|
path: `${this._basePath}.argument`,
|
||||||
|
@ -3180,6 +3180,7 @@
|
|||||||
<template id="hotkey-list-item-menu-template"><div class="popup-menu-container" tabindex="-1" role="dialog"><div class="popup-menu"><div class="popup-menu-body">
|
<template id="hotkey-list-item-menu-template"><div class="popup-menu-container" tabindex="-1" role="dialog"><div class="popup-menu"><div class="popup-menu-body">
|
||||||
<button class="popup-menu-item" data-menu-action="clearInputs">Clear input</button>
|
<button class="popup-menu-item" data-menu-action="clearInputs">Clear input</button>
|
||||||
<button class="popup-menu-item" data-menu-action="resetInput">Reset input</button>
|
<button class="popup-menu-item" data-menu-action="resetInput">Reset input</button>
|
||||||
|
<button class="popup-menu-item" data-menu-action="resetArgument">Reset argument</button>
|
||||||
<button class="popup-menu-item" data-menu-action="delete">Delete</button>
|
<button class="popup-menu-item" data-menu-action="delete">Delete</button>
|
||||||
</div></div></div></template>
|
</div></div></div></template>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user