Simplify platform-specific keyboard layouts with Accel key and global platform variable (#748)

* Simplify platform-specific keyboard layouts with Accel key and global platform variable


Co-authored-by: Dennis <dennis@kobert.dev>
This commit is contained in:
Keavon Chambers
2022-08-13 13:28:02 +02:00
committed by GitHub
co-authored by Dennis
parent d8ae727ea9
commit 776992a297
24 changed files with 240 additions and 315 deletions
@@ -195,8 +195,11 @@ export default defineComponent({
let key = keyWithLabel.key;
const label = keyWithLabel.label;
// Replace Alt with Option on Mac
if (key === "Alt" && platformIsMac()) key = "Option";
// Replace Alt and Accel keys with their Mac-specific equivalents
if (platformIsMac()) {
if (key === "Alt") key = "Option";
if (key === "Accel") key = "Command";
}
// Either display an icon...
// @ts-expect-error We want undefined if it isn't in the object
+6 -2
View File
@@ -66,8 +66,11 @@ impl JsEditorHandle {
return;
}
// Get the editor instances, dispatch the message, and store the `FrontendMessage` queue response
let frontend_messages = EDITOR_INSTANCES.with(|instances| {
// Mutably borrow the editors, and if successful, we can access them in the closure
instances.try_borrow_mut().map(|mut editors| {
// Get the editor instance for this editor ID, then dispatch the message to the backend, and return its response `FrontendMessage` queue
editors
.get_mut(&self.editor_id)
.expect("EDITOR_INSTANCES does not contain the current editor_id")
@@ -75,9 +78,10 @@ impl JsEditorHandle {
})
});
// Process any `FrontendMessage` responses resulting from the backend processing the dispatched message
if let Ok(frontend_messages) = frontend_messages {
// Send each `FrontendMessage` to the JavaScript frontend
for message in frontend_messages.into_iter() {
// Send each FrontendMessage to the JavaScript frontend
self.send_frontend_message_to_js(message);
}
}
@@ -115,7 +119,7 @@ impl JsEditorHandle {
_ => Platform::Unknown,
};
self.dispatch(PortfolioMessage::SetPlatform { platform });
self.dispatch(GlobalsMessage::SetPlatform { platform });
self.dispatch(Message::Init);
}