motion-prime/elements/base_element.rb in motion-prime-0.6.0 vs motion-prime/elements/base_element.rb in motion-prime-0.7.0
- old
+ new
@@ -27,11 +27,11 @@
@block = options[:block]
@view_name = self.class_name_without_kvo.demodulize.underscore.gsub(/(_draw)?_element/, '')
end
# def dealloc
- # pp 'deallocating elemenet', self.name, self.to_s, view_class#, view.try(:to_s)
+ # pp 'Deallocating elemenet', self.name, self.to_s, view_class#, view.try(:to_s)
# super
# end
def add_target(target = nil, action = 'on_click:', event = :touch)
return false unless self.view
@@ -43,13 +43,18 @@
render!(&block)
end
end
def render!(&block)
- screen.add_view class_factory(view_class), computed_options do |view|
+ view = screen.add_view class_factory(view_class), computed_options do |view|
@view = view
block.try(:call, view, self)
end
+
+ if computed_options.has_key?(:delegate) && computed_options[:delegate].respond_to?(:delegated_by)
+ computed_options[:delegate].delegated_by(view)
+ end
+ view
end
# Lazy-computing options
def computed_options
compute_options! unless @computed_options
\ No newline at end of file