Skip to content

External keyboard shortcuts are not activated #483

Description

@holzschu

Describe the bug
When you add external keyboard shortcuts to SwiftTerm using UIKeyCommand, they don't work as expected.

To Reproduce

  • take a working app using SwiftTerm on iOS
  • add an override var keyCommands: [UIKeyCommand] (see instructions for example here: https://www.avanderlee.com/swift/uikeycommand-keyboard-shortcuts/ ), I'm putting a minimal sample code below.
  • the keyCommands variable is called (a breakpoint activates), but the functions defined in the keyboard shortcut are never called.

Expected behavior
I would expect the functions defined in the keyboard shortcut to be called.

Additional context

Adding this source code to a working iOS project defines an external keyboard shortcut using command + K to write something in the log screen.

import Foundation
import UIKit
import SwiftTerm

extension TerminalView {
    
    @objc private func clearScreen(_ sender: UIBarButtonItem) {
        NSLog("clearScreen has been called")
    }
    
    open override var keyCommands: [UIKeyCommand]? {
        let basicKeyCommands = [
            UIKeyCommand(input: "k", modifierFlags:.command, action: #selector(clearScreen), discoverabilityTitle: "Clear screen"),
        ]
        return basicKeyCommands
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions