Class: MotionWiretap::WiretapControl
- Inherits:
-
WiretapView
- Object
- Wiretap
- WiretapTarget
- WiretapKvo
- WiretapView
- MotionWiretap::WiretapControl
- Defined in:
- lib/motion-wiretap/ios/wiretap_ios.rb
Instance Attribute Summary
Attributes inherited from WiretapKvo
Attributes inherited from WiretapTarget
Attributes inherited from Wiretap
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize(target, &block) ⇒ WiretapControl
constructor
A new instance of WiretapControl.
-
#on(control_event, options = {}, &block) ⇒ Object
control_event can be any UIControlEventConstant, or any symbol found in wiretap_control_events.rb, or an array of UIControlEventConstants or symbols.
- #teardown ⇒ Object
Methods inherited from WiretapView
Methods inherited from WiretapKvo
#bind_to, #observeValueForKeyPath
Methods inherited from Wiretap
#and_then, #cancel!, #combine, #dealloc, #enqueue, #filter, #listen, #map, #on_error, #queue, #reduce, #trigger_changed, #trigger_changed_on, #trigger_completed, #trigger_completed_on, #trigger_error, #trigger_error_on
Constructor Details
#initialize(target, &block) ⇒ WiretapControl
Returns a new instance of WiretapControl.
56 57 58 59 |
# File 'lib/motion-wiretap/ios/wiretap_ios.rb', line 56 def initialize(target, &block) super @control_events = [] end |
Instance Method Details
#handle_event(event) ⇒ Object
79 80 81 |
# File 'lib/motion-wiretap/ios/wiretap_ios.rb', line 79 def handle_event(event) trigger_changed(event) end |
#on(control_event, options = {}, &block) ⇒ Object
control_event can be any UIControlEventConstant, or any symbol found in wiretap_control_events.rb, or an array of UIControlEventConstants or symbols. Since UIView implements ‘on` to accept a gesture, this method calls `super` when the symbol isn’t a control
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/motion-wiretap/ios/wiretap_ios.rb', line 65 def on(control_event, ={}, &block) begin control_event = ControlEvents.convert(control_event) self.target.addTarget(self, action: 'handle_event:', forControlEvents: control_event) @control_events << control_event rescue ControlEventNotFound super(control_event, , &block) else super(nil, , &block) end return self end |
#teardown ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/motion-wiretap/ios/wiretap_ios.rb', line 83 def teardown remove_event = (-> (event) { self.target.removeTarget(self, action: 'handle_event:', forControlEvents: event) }).weak! @control_events.each(&remove_event) super end |