Adonit / LAMY-iPadOS-SDK

0 stars 0 forks source link

Shortcuts randomly not being executed #7

Closed Kaven01 closed 3 months ago

Kaven01 commented 3 months ago

I've encountered one more problem with LamyViewControllerShortCutButtonAIdentifier (and ButtonB too) . I can assigned different shortcuts to stylus buttons, and for a while it works. If I watch "Activity Message" in LamyViewControllerDebugStatusIdentifier, I can see "LamyShortuct1 Started" when I press the button, and "LamyShortcut1 Stopped" when I release it (and the same for Shortcut 2). Shortcut actions are correctly launched.

However after some shortcut switching, the shortcut handlers stop to be called. If I watch "Activity Message" in LamyViewControllerDebugStatusIdentifier, I can see only "LamyShortuct1 Stopped", but never "LamyShortcut1 Started" (same for shortcut 2). It looks like button press is no longer recognized, only button release.

The LamyViewControllerShortCutButtonAIdentifier controller is created inside a page of UINavigationController, which is presented as popover. After some opening and closing of the popover, changing shortcuts in UI etc. buttons suddenly start launching assigned actions again. I don't have a reliable way to either make system stop reacting to buttons or start again, but I encounter it fairly quickly, after only few changes in shortcut assignements.

This is how I define shortcuts:

        let manager = LamyStylusManager.sharedInstance()
        var shortcut: LamyShortcut
        shortcut = LamyShortcut(descriptiveText: NSLocalizedString("No action", comment: "LAMY shortcut"), key: "selection", target: self, selector: #selector(self.DoClickNothing))
        manager?.addShortcutOption(shortcut)

        shortcut = LamyShortcut(descriptiveText: NSLocalizedString("Select tool", comment: "LAMY shortcut"), key: "selection", target: self, selector: #selector(self.DoClickToolSelection))
//        manager?.addShortcutOption(shortcut)
        manager?.addShortcutOptionButton2Default(shortcut)

        shortcut = LamyShortcut(descriptiveText: NSLocalizedString("Ink tool", comment: "LAMY shortcut"), key: "ink", target: self, selector: #selector(self.DoClickToolInk))
//        manager?.addShortcutOption(shortcut)
        manager?.addShortcutOptionButton1Default(shortcut)

        shortcut = LamyShortcut(descriptiveText: NSLocalizedString("Eraser tool", comment: "LAMY shortcut"), key: "eraser", target: self, selector: #selector(self.DoClickToolEraser))
        manager?.addShortcutOption(shortcut)

        shortcut = LamyShortcut(descriptiveText: NSLocalizedString("Choose color", comment: "LAMY shortcut"), key: "color", target: self, selector: #selector(self.DoClickToolColor))
        manager?.addShortcutOption(shortcut)

And these are my testing shortcut handlers:

    @objc internal func DoClickToolSelection() {
        DispatchQueue.main.async {
            print("SELECTION")
        }
    }
    @objc internal func DoClickToolInk() {
        DispatchQueue.main.async {
            print("INK")
        }
    }
    @objc internal func DoClickToolEraser() {
        DispatchQueue.main.async {
            print("ERASER")
        }
    }
    @objc internal func DoClickToolColor() {
        DispatchQueue.main.async {
            print("COLOR")
        }
    }
    @objc internal func DoClickNothing() {
    }
adonitDevel commented 3 months ago

Hi @Kaven01, I followed the steps you mentioned but after a certain time, I still couldn't reproduce the problem you mentioned.

Kaven01 commented 3 months ago

I tried it again today, and could not reproduce it either. Yesterday the problem was certainly there, but it seems its gone today. Maybe some Apple magic was involved.

OK, sorry then for false issue. Everything seems to be working now.