Class: UITextField_Delegate
- Defined in:
- lib/formotion/patch/ui_text_field.rb
Instance Attribute Summary collapse
-
#on_change_callback ⇒ Object
Called from [textField addTarget:block action:‘call’ forControlEvents:UIControlEventEditingChanged], NOT a UITextFieldDelegate method.
Instance Method Summary collapse
- #on_change(theTextField) ⇒ Object
- #textField(theTextField, shouldChangeCharactersInRange: range, replacementString: string) ⇒ Object
- #textFieldDidBeginEditing(theTextField) ⇒ Object
- #textFieldDidEndEditing(theTextField) ⇒ Object
- #textFieldShouldBeginEditing(theTextField) ⇒ Object
- #textFieldShouldClear(theTextField) ⇒ Object
- #textFieldShouldEndEditing(theTextField) ⇒ Object
- #textFieldShouldReturn(theTextField) ⇒ Object
Instance Attribute Details
#on_change_callback ⇒ Object
Called from [textField addTarget:block
action:'call'
forControlEvents:UIControlEventEditingChanged],
NOT a UITextFieldDelegate method.
98 99 100 |
# File 'lib/formotion/patch/ui_text_field.rb', line 98 def on_change_callback @on_change_callback end |
Instance Method Details
#on_change(theTextField) ⇒ Object
147 148 149 150 151 |
# File 'lib/formotion/patch/ui_text_field.rb', line 147 def on_change(theTextField) if self.on_change_callback self.on_change_callback.call(theTextField) end end |
#textField(theTextField, shouldChangeCharactersInRange: range, replacementString: string) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/formotion/patch/ui_text_field.rb', line 131 def textField(theTextField, shouldChangeCharactersInRange:range, replacementString:string) if self.shouldChangeCharactersInRange_callback return self.shouldChangeCharactersInRange_callback.call(theTextField, range, string) end # fix for UITextField in iOS7 http://stackoverflow.com/questions/19569688/uitextfield-spacebar-does-not-advance-cursor-in-ios-7/20129483#20129483 if BW::Device.ios_version >= "7.0" if range.location == theTextField.text.length && string == " " theTextField.text = theTextField.text.stringByAppendingString("\u00a0") return false end end true end |
#textFieldDidBeginEditing(theTextField) ⇒ Object
107 108 109 110 111 |
# File 'lib/formotion/patch/ui_text_field.rb', line 107 def textFieldDidBeginEditing(theTextField) if self.textFieldDidBeginEditing_callback return self.textFieldDidBeginEditing_callback.call(theTextField) end end |
#textFieldDidEndEditing(theTextField) ⇒ Object
125 126 127 128 129 |
# File 'lib/formotion/patch/ui_text_field.rb', line 125 def textFieldDidEndEditing(theTextField) if self.textFieldDidEndEditing_callback return self.textFieldDidEndEditing_callback.call(theTextField) end end |
#textFieldShouldBeginEditing(theTextField) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/formotion/patch/ui_text_field.rb', line 100 def textFieldShouldBeginEditing(theTextField) if self.textFieldShouldBeginEditing_callback return self.textFieldShouldBeginEditing_callback.call(theTextField) end true end |
#textFieldShouldClear(theTextField) ⇒ Object
153 154 155 156 157 158 |
# File 'lib/formotion/patch/ui_text_field.rb', line 153 def textFieldShouldClear(theTextField) if self.textFieldShouldClear_callback return self.textFieldShouldClear_callback.call(theTextField) end true end |
#textFieldShouldEndEditing(theTextField) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/formotion/patch/ui_text_field.rb', line 113 def textFieldShouldEndEditing(theTextField) if self.textFieldShouldEndEditing_callback return self.textFieldShouldEndEditing_callback.call(theTextField) end if BW::Device.ios_version >= "7.0" theTextField.text = theTextField.text.gsub("\u00a0", " ").strip end true end |
#textFieldShouldReturn(theTextField) ⇒ Object
160 161 162 163 164 165 |
# File 'lib/formotion/patch/ui_text_field.rb', line 160 def textFieldShouldReturn(theTextField) if self.textFieldShouldReturn_callback return self.textFieldShouldReturn_callback.call(theTextField) end true end |