focus the shortcut webview in vscode

This commit is contained in:
2021-10-14 11:44:54 -04:00
parent 9016870d65
commit b8b95d2a61

View File

@@ -139,7 +139,9 @@
// TODO restore focus to previous frame first
(_runCommand command inputText)))}
{(warningMessage "$key is not mapped to a shortcut in this context")(return)}))))
(set shortcutPanel.webview.html (shortcutPanelHtml prefixMap))))
(set shortcutPanel.webview.html (shortcutPanelHtml prefixMap))
(infoMessage "posting message")
(shortcutPanel.webview.postMessage (object command "focus"))))
(function shortcutPanelHtml [:Map<String,ShortcutKey> prefixMap]
(let [shortcutParagraphs
@@ -160,6 +162,15 @@
$(shortcutParagraphs.join "")
<script>
const vscode = acquireVsCodeApi();
window.addEventListener('message', function(event) {
var message = event.data;
switch (message.command) {
case 'focus':
window.focus();
break;
}
});
window.addEventListener('keydown', function (e) {
vscode.postMessage(e.key);
});