Commit 53092d1d by Daniel Dahan

issue-296: Fixed where textFieldShouldClear delegate method was not being respected

parent 543efc42
......@@ -108,7 +108,7 @@ class AppMenuViewController: MenuViewController {
view.backgroundColor = MaterialColor.black
}
/// Prepares the add button.
/// Prepares the menuView.
private func prepareMenuView() {
var image: UIImage? = MaterialIcon.cm.add
let menuButton: FabButton = FabButton()
......
......@@ -84,6 +84,34 @@ class ViewController: UIViewController, TextFieldDelegate {
/// Executed when the 'return' key is pressed when using the emailField.
func textFieldShouldReturn(textField: UITextField) -> Bool {
(textField as! TextField).detailLabelHidden = 0 == textField.text?.utf16.count
return false
return true
}
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
print("Should Begin")
return true
}
func textFieldDidBeginEditing(textField: UITextField) {
print("Did Begin")
}
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
print("Should End")
return true
}
func textFieldDidEndEditing(textField: UITextField) {
print("Did End")
}
func textFieldShouldClear(textField: UITextField) -> Bool {
print("Should Clear")
return true
}
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
print("Should Change")
return true
}
}
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '1.39.6'
s.version = '1.39.7'
s.license = 'BSD'
s.summary = 'Express your creativity with Material, an animation and graphics framework for Google\'s Material Design and Apple\'s Flat UI in Swift.'
s.homepage = 'http://cosmicmind.io'
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.39.6</string>
<string>1.39.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -492,6 +492,10 @@ public class TextField : UITextField {
prepareTitleLabel()
prepareLineLayer()
reloadView()
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
addTarget(self, action: #selector(textFieldValueChanged), forControlEvents: .ValueChanged)
}
/// Reloads the view.
......@@ -503,7 +507,11 @@ public class TextField : UITextField {
/// Clears the textField text.
internal func handleClearButton() {
if false == delegate?.textFieldShouldClear?(self) {
return
}
text = ""
sendActionsForControlEvents(.ValueChanged)
}
/// Ahdnler when text value changed.
......@@ -567,9 +575,6 @@ public class TextField : UITextField {
} else {
titleLabel.alpha = 0
}
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
}
/// Prepares the detailLabel.
......@@ -582,12 +587,6 @@ public class TextField : UITextField {
} else {
showDetailLabel()
}
if nil == titleLabel {
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd)
}
addTarget(self, action: #selector(textFieldValueChanged), forControlEvents: .ValueChanged)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment