//
//  UIKeyCommand+ConvInit.swift
//  App
//
//  Created by James Magahern on 9/21/20.
//

import UIKit

extension NSObject {
    @objc fileprivate func _null() {}
}

extension UIKeyCommand {
    public static func null() -> UIKeyCommand {
        UIKeyCommand(modifiers: [], input: "", title: "", action: #selector(_null))
    }
    
    public func isNull() -> Bool {
        return action == #selector(_null)
    }
    
    convenience init(modifiers: UIKeyModifierFlags, input: String, title: String, action: Selector) {
        self.init(input: input, modifierFlags: modifiers, action: action)
        self.title = title
    }
    
    public func prioritizeOverSystem() -> UIKeyCommand {
        if #available(iOS 15.0, *) {
            self.wantsPriorityOverSystemBehavior = true
        }
        
        return self
    }
}
