Ensure new text items are on the canvas.
This commit is contained in:
parent
675c60bf4e
commit
5973c326de
|
@ -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,
|
||||
|
|
|
@ -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: -
|
||||
|
|
Loading…
Reference in New Issue