Skip to content

Commit 4749fb6

Browse files
Require CMD for Pack and Unpack shortcuts (#1275)
1 parent 4af8e8e commit 4749fb6

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Stitch/App/Shortcut/PatchNodeShortcutKeys.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftUI
1010

1111
// MARK: PATCH SHORTCUTS
1212

13+
// Require CMD
1314
let ADD_PACK_NODE_SHORTCUT: KeyEquivalent = "P"
1415
let ADD_UNPACK_NODE_SHORTCUT: KeyEquivalent = "U"
1516

@@ -88,29 +89,35 @@ extension Character {
8889
}
8990
}
9091

91-
func patchFromShortcutKey(isShiftDown: Bool) -> Patch? {
92+
func patchFromShortcutKey(isShiftDown: Bool,
93+
isCommandDown: Bool) -> Patch? {
9294
log("patchFromShortcutKey: isShiftDown: \(isShiftDown)")
95+
log("patchFromShortcutKey: isCommandDown: \(isCommandDown)")
9396

9497
let lowercaseCharacter = self.lowercased().toCharacter
9598

9699
if isShiftDown {
97100
switch lowercaseCharacter {
98-
// Always requires shift ?
99101
case NOT_NODE_SHORTCUT.character.lowercased().toCharacter:
100102
return .not
101103
default:
102104
break
103105
}
104106
}
105107

108+
if isCommandDown {
109+
switch lowercaseCharacter {
110+
case ADD_PACK_NODE_SHORTCUT.character.lowercased().toCharacter:
111+
return .sizePack
112+
case ADD_UNPACK_NODE_SHORTCUT.character.lowercased().toCharacter:
113+
return .sizeUnpack
114+
default:
115+
break
116+
}
117+
}
118+
106119
switch lowercaseCharacter {
107120

108-
case ADD_PACK_NODE_SHORTCUT.character.lowercased().toCharacter:
109-
return .sizePack
110-
111-
case ADD_UNPACK_NODE_SHORTCUT.character.lowercased().toCharacter:
112-
return .sizeUnpack
113-
114121
case ADD_SPLITTER_NODE_SHORTCUT.character.lowercased().toCharacter:
115122
return .splitter
116123

Stitch/Graph/Node/Patch/Type/Interaction/Keyboard/KeyPressActions.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ extension StitchStore {
163163
// Else: If option is not required for shortcuts, and shortcuts are not disabled, try to treat the keypress as a shortcut.
164164
else if !self.isOptionRequiredForShortcut,
165165
!document.shouldDisablePatchShortcuts,
166-
let patch = char.patchFromShortcutKey(isShiftDown: document.keypressState.isShiftPressed) {
166+
let patch = char.patchFromShortcutKey(
167+
isShiftDown: document.keypressState.isShiftPressed,
168+
isCommandDown: document.keypressState.isCommandPressed) {
167169

168170
if document.reduxFocusedField?.isInputPortSelected ?? false {
169171
document.nodeCreatedWhileInputSelected(patch: patch)

0 commit comments

Comments
 (0)