Skip to content

Commit 4e245b0

Browse files
committed
Add cmd+enter keycommand
1 parent dfc5175 commit 4e245b0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

MessageViewController/MessageView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public final class MessageView: UIView, MessageTextViewListener {
1818
internal let UITextViewContentSizeKeyPath = #keyPath(UITextView.contentSize)
1919
internal let topBorderLayer = CALayer()
2020
internal var contentView: UIView?
21+
internal var buttonAction: Selector?
2122

2223
internal override init(frame: CGRect) {
2324
super.init(frame: frame)
@@ -155,6 +156,12 @@ public final class MessageView: UIView, MessageTextViewListener {
155156

156157
public func addButton(target: Any, action: Selector) {
157158
button.addTarget(target, action: action, for: .touchUpInside)
159+
buttonAction = action
160+
}
161+
162+
public override var keyCommands: [UIKeyCommand]? {
163+
guard let action = buttonAction else { return nil }
164+
return [UIKeyCommand(input: "\r", modifierFlags: .command, action: action)]
158165
}
159166

160167
// MARK: Overrides

0 commit comments

Comments
 (0)