You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for this amazing package! It has been incredibly useful in my project. However, I have a requirement that I am hoping to get some guidance on.
I need to create keyboard shortcuts that are only active when my app is in use. I want to avoid having these shortcuts override global shortcuts or interfere with other applications. I noticed that there is a brief explanation in the readme about this, but it does not provide much detail. Could you please provide more detailed guidance or examples on how to achieve in-app specific shortcuts using this package?
Here's a summary of what I have so far:
I have defined my shortcuts using the KeyboardShortcuts.Name extension.
I am using the KeyboardShortcuts.onKeyUp to attach the shortcuts to view components.
import KeyboardShortcuts
extensionKeyboardShortcuts.Name{staticlettextSearch=Self("textSearch", default:.init(.f, modifiers:[.command]))// ... other shortcuts}
structTextEditorSearchBar:View{@EnvironmentObjectvarsearchState:TextEditorSearchBarState@FocusStateprivatevarisSearchFieldFocused:Boolvarbody:someView{HStack(spacing:0){// Set spacing to 0 to remove padding between elementsTextField("Search...", text: $searchState.searchText).focused($isSearchFieldFocused)}.onAppear{// Register the keyboard shortcutKeyboardShortcuts.onKeyUp(for:.textSearch){
isSearchFieldFocused = true
}}}}
Goal
I want to ensure that these shortcuts are only active when my app is in use and do not interfere with global shortcuts or other applications.
Questions
What is the best practice to achieve in-app specific shortcuts using this package?
Can you provide a detailed example or guidance on implementing this?
Thank you in advance for your assistance!
The text was updated successfully, but these errors were encountered:
Custom global keyboard shortcuts for your macOS app
Handling local shortcuts is a non-goal.
However, when #164 is done, you could use the recorder from this package, store the keyboard shortcut yourself in UserDefaults, and then use the SwiftUI .keyboardShortcut() method.
Description
First of all, thank you for this amazing package! It has been incredibly useful in my project. However, I have a requirement that I am hoping to get some guidance on.
I need to create keyboard shortcuts that are only active when my app is in use. I want to avoid having these shortcuts override global shortcuts or interfere with other applications. I noticed that there is a brief explanation in the readme about this, but it does not provide much detail. Could you please provide more detailed guidance or examples on how to achieve in-app specific shortcuts using this package?
Here's a summary of what I have so far:
KeyboardShortcuts.Name
extension.KeyboardShortcuts.onKeyUp
to attach the shortcuts to view components.Goal
I want to ensure that these shortcuts are only active when my app is in use and do not interfere with global shortcuts or other applications.
Questions
Thank you in advance for your assistance!
The text was updated successfully, but these errors were encountered: