refactored textfield
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
acd688405d
commit
d573002be5
@ -47,6 +47,11 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
/// Set to true to hide the blinking textField cursor.
|
||||
open var hideBlinkingCaret = false
|
||||
open var enableClipboardActions: Bool = true
|
||||
open var onDidDeleteBackwards: (() -> Void)?
|
||||
|
||||
/// Key of whether or not updateView() is called in setNeedsUpdate()
|
||||
open var shouldUpdateView: Bool = true
|
||||
|
||||
@ -209,6 +214,23 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
||||
return success
|
||||
}
|
||||
|
||||
open override func caretRect(for position: UITextPosition) -> CGRect {
|
||||
|
||||
if hideBlinkingCaret {
|
||||
return .zero
|
||||
}
|
||||
|
||||
let caretRect = super.caretRect(for: position)
|
||||
return CGRect(origin: caretRect.origin, size: CGSize(width: 1, height: caretRect.height))
|
||||
}
|
||||
|
||||
open override func deleteBackward() {
|
||||
super.deleteBackward()
|
||||
onDidDeleteBackwards?()
|
||||
}
|
||||
|
||||
open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { enableClipboardActions }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user