Skip to content

Commit e98f81c

Browse files
authored
Merge pull request GitHawkApp#2 from BasThomas/enter-keycommand
Add ⌘ + Enter keycommand
2 parents 5b913a2 + 4e245b0 commit e98f81c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

MessageViewController/MessageView.swift

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

2122
internal override init(frame: CGRect) {
2223
super.init(frame: frame)
@@ -136,6 +137,12 @@ public final class MessageView: UIView, MessageTextViewListener {
136137

137138
public func addButton(target: Any, action: Selector) {
138139
button.addTarget(target, action: action, for: .touchUpInside)
140+
buttonAction = action
141+
}
142+
143+
public override var keyCommands: [UIKeyCommand]? {
144+
guard let action = buttonAction else { return nil }
145+
return [UIKeyCommand(input: "\r", modifierFlags: .command, action: action)]
139146
}
140147

141148
// MARK: Overrides

0 commit comments

Comments
 (0)