Class: UITextView
Instance Method Summary collapse
-
#off(*events) ⇒ Object
Removes all events that were bound with ‘on`.
-
#on(*events, &block) ⇒ Object
Add event handlers to UITextView, with the same syntax as ‘UIControl` objects.
- #sugarcube_callbacks(notification = nil) ⇒ Object
Instance Method Details
#off(*events) ⇒ Object
Removes all events that were bound with ‘on`. Present tense and past simple aliases are provided. (e.g. `editing_did_change` and `change`)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ios/sugarcube-events/uitextview.rb', line 49 def off(*events) if events.length == 0 events = self.sugarcube_callbacks.keys end events.each do |event| case event when :editing_did_begin, :begin, UITextViewTextDidBeginEditingNotification _offEventNotification(UITextViewTextDidBeginEditingNotification) when :editing_did_change, :change, UITextViewTextDidChangeNotification _offEventNotification(UITextViewTextDidChangeNotification) when :editing_did_end, :end, UITextViewTextDidEndEditingNotification _offEventNotification(UITextViewTextDidEndEditingNotification) else raise "Unknown or unsupported event #{event} in UITextView#on" end end self end |
#on(*events, &block) ⇒ Object
Add event handlers to UITextView, with the same syntax as ‘UIControl` objects. Present tense and past simple aliases are provided. (e.g. `editing_did_change` and `change`)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ios/sugarcube-events/uitextview.rb', line 23 def on(*events, &block) events.each do |event| case event when :editing_did_begin, :begin, UITextViewTextDidBeginEditingNotification _onEventNotification(UITextViewTextDidBeginEditingNotification, &block) when :editing_did_change, :change, UITextViewTextDidChangeNotification _onEventNotification(UITextViewTextDidChangeNotification, &block) when :editing_did_end, :end, UITextViewTextDidEndEditingNotification _onEventNotification(UITextViewTextDidEndEditingNotification, &block) else raise "Unknown or unsupported event #{event} in UITextView#on" end end self end |
#sugarcube_callbacks(notification = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/ios/sugarcube-events/uitextview.rb', line 3 def sugarcube_callbacks(notification=nil) @sugarcube_callbacks ||= {} if notification @sugarcube_callbacks[notification] ||= SugarCubeNotificationForgetter.new return @sugarcube_callbacks[notification] else return @sugarcube_callbacks end end |