diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift b/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift index 53f1f2cfc..beb16d220 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorTextViewController.swift @@ -75,8 +75,8 @@ private class VAlignTextView: UITextView { override var keyCommands: [UIKeyCommand]? { return [ - UIKeyCommand(input: "\r", modifierFlags: .command, action: #selector(self.modifiedReturnPressed(sender:)), discoverabilityTitle: "Send Message"), - UIKeyCommand(input: "\r", modifierFlags: .alternate, action: #selector(self.modifiedReturnPressed(sender:)), discoverabilityTitle: "Send Message") + UIKeyCommand(input: "\r", modifierFlags: .command, action: #selector(self.modifiedReturnPressed(sender:)), discoverabilityTitle: "Add Text"), + UIKeyCommand(input: "\r", modifierFlags: .alternate, action: #selector(self.modifiedReturnPressed(sender:)), discoverabilityTitle: "Add Text") ] } @@ -295,7 +295,7 @@ public class ImageEditorTextViewController: OWSViewController, VAlignTextViewDel // Ensure continuity of the new text item's location // with its apparent location in this text editor. - let locationInView = view.convert(textView.bounds.center, from: textView) + let locationInView = view.convert(textView.bounds.center, from: textView).clamp(view.bounds) let textCenterImageUnit = ImageEditorCanvasView.locationImageUnit(forLocationInView: locationInView, viewBounds: viewBounds, model: model, diff --git a/SignalMessaging/categories/UIView+OWS.swift b/SignalMessaging/categories/UIView+OWS.swift index 3b9656d0f..3e1453410 100644 --- a/SignalMessaging/categories/UIView+OWS.swift +++ b/SignalMessaging/categories/UIView+OWS.swift @@ -270,6 +270,11 @@ public extension CGPoint { return CGPoint(x: sin(angle), y: cos(angle)) } + + public func clamp(_ rect: CGRect) -> CGPoint { + return CGPoint(x: x.clamp(rect.minX, rect.maxX), + y: y.clamp(rect.minY, rect.maxY)) + } } // MARK: -