popup: right-click / ctrl-click on a name opens editor

This commit is contained in:
tophf 2017-04-17 19:48:39 +03:00
parent 01d59192a3
commit 0d6f7e0a4b

View File

@ -201,8 +201,7 @@ function createStyleElement({
id: 'style-' + style.id, id: 'style-' + style.id,
styleId: style.id, styleId: style.id,
className: entry.className + ' ' + (style.enabled ? 'enabled' : 'disabled'), className: entry.className + ' ' + (style.enabled ? 'enabled' : 'disabled'),
onmousedown: handleEvent.middleClick, onmousedown: handleEvent.maybeEdit,
onauxclick: handleEvent.middleClick,
}); });
const checkbox = $('.checker', entry); const checkbox = $('.checker', entry);
@ -324,13 +323,16 @@ Object.assign(handleEvent, {
close(); close();
}, },
middleClick(event) { maybeEdit(event) {
if (event.button != 1) { if (!(
event.button == 0 && event.ctrlKey ||
event.button == 1 ||
event.button == 2)) {
return; return;
} }
// open an editor on middleclick // open an editor on middleclick
if (event.target.matches('.entry, .style-name, .style-edit-link')) { if (event.target.matches('.entry, .style-name, .style-edit-link')) {
$('.style-edit-link', this).click(); this.onmouseup = () => $('.style-edit-link', this).click();
event.preventDefault(); event.preventDefault();
return; return;
} }