mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 00:58:11 +08:00
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:
co-authored by
Dennis
parent
d8ae727ea9
commit
776992a297
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user