Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shortcut with keyholder #349

Merged
merged 34 commits into from
Feb 2, 2024
Merged

Add shortcut with keyholder #349

merged 34 commits into from
Feb 2, 2024

Conversation

AkaShark
Copy link
Collaborator

@AkaShark AkaShark commented Jan 21, 2024

closed #290

@AkaShark AkaShark changed the base branch from main to dev January 21, 2024 03:30
@tisfeng
Copy link
Owner

tisfeng commented Jan 21, 2024

App crashed when I use the shortcut key Opt+S in old settings, I only set a new shortcut key Opt+A in new settings, Opt+A works fine.

Magnet/HotKeyCenter.swift:140: Assertion failed: Invalid hot key id
image

@AkaShark
Copy link
Collaborator Author

App crashed when I use the shortcut key Opt+S in old settings, I only set a new shortcut key Opt+A in new settings, Opt+A works fine.

Magnet/HotKeyCenter.swift:140: Assertion failed: Invalid hot key id
image

okay, I repeated this crash, seems caused by the conflict between keyholder and MAShortcut, I also purposely used different Key values.... Let me see more details, I will fix this later.

@tisfeng
Copy link
Owner

tisfeng commented Jan 21, 2024

The shortcut keys group looks inconsistent with the overall page layout.

Maybe we can move the shortcut keys to a separate page and optimize the layout. For example, there is no need for dividing lines, and the shortcut key view needs to be left aligned.

image

@AkaShark
Copy link
Collaborator Author

The shortcut keys group looks inconsistent with the overall page layout.

Maybe we can move the shortcut keys to a separate page and optimize the layout. For example, there is no need for dividing lines, and the shortcut key view needs to be left aligned.

image

That sounds like a good idea! I will move shortcut to another page, and optimize the layout

@tisfeng
Copy link
Owner

tisfeng commented Jan 21, 2024

MAShortcut

App crashed when I use the shortcut key Opt+S in old settings, I only set a new shortcut key Opt+A in new settings, Opt+A works fine.

Magnet/HotKeyCenter.swift:140: Assertion failed: Invalid hot key id
image

I just fixed it in a simple way, and I didn't confirm the conflict between keyholder and MAShortcut.

    if (!EasydictNewAppManager.shared.enable) {
        [EZMenuItemManager.shared setup];
        [EZShortcut setup];
    } else {
        [Shortcut setupShortcut];
    }

@AkaShark
Copy link
Collaborator Author

MAShortcut

App crashed when I use the shortcut key Opt+S in old settings, I only set a new shortcut key Opt+A in new settings, Opt+A works fine.

Magnet/HotKeyCenter.swift:140: Assertion failed: Invalid hot key id
image

I just fixed it in a simple way, and I didn't confirm the conflict between keyholder and MAShortcut.

    if (!EasydictNewAppManager.shared.enable) {
        [EZMenuItemManager.shared setup];
        [EZShortcut setup];
    } else {
        [Shortcut setupShortcut];
    }

You are right, that is a smart way !

@tisfeng
Copy link
Owner

tisfeng commented Jan 21, 2024

This shortcut key layout looks weird.

image

@AkaShark
Copy link
Collaborator Author

This shortcut key layout looks weird.

image

yeah, that is my problem, in UIKit we can use NSMenuItem to add keyEquicalent and keyEquivalentModifierMask
CleanShot 2024-01-21 at 20 59 57@2x
But in SwiftUI I can't find the property
CleanShot 2024-01-21 at 21 01 23@2x
If I use .keyboardShortcut user can't add a double modifier key. I tried to use HStack but it did seem not good 😭

@tisfeng
Copy link
Owner

tisfeng commented Jan 21, 2024

I tried this code, looks good.

image

@AkaShark
Copy link
Collaborator Author

This feature is ready. Please review the change.

@phlpsong
Copy link
Collaborator

There are some localized strings marked as need_review, do we need to update this?

Screenshot 2024-01-31 at 22 17 12

@AkaShark
Copy link
Collaborator Author

There are some localized strings marked as need_review, do we need to update this?

yeah, I think we need to mark the changes that we confirm as reviewed. I have marked this as reviewed.

@AkaShark AkaShark requested review from tisfeng and phlpsong February 1, 2024 09:58
phlpsong
phlpsong previously approved these changes Feb 1, 2024
tisfeng
tisfeng previously approved these changes Feb 1, 2024
Copy link
Owner

@tisfeng tisfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@AkaShark AkaShark dismissed stale reviews from tisfeng and phlpsong via e3c5aa4 February 1, 2024 15:35
@AkaShark AkaShark requested review from tisfeng and phlpsong February 2, 2024 02:43
@tisfeng
Copy link
Owner

tisfeng commented Feb 2, 2024

I will merge this PR soon if there are no other questions.

@tisfeng tisfeng merged commit b559959 into tisfeng:dev Feb 2, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants