From 690b5a14fb1c12176b20970bc4f0d38bc1aaf347 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Wed, 18 Mar 2015 20:32:41 -0400 Subject: [PATCH] Allows you to set a UIView's userInteractionEnabled property. --- motion/ruby_motion_query/stylers/ui_view_styler.rb | 6 ++++++ spec/stylers/_ui_view_styler.rb | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/motion/ruby_motion_query/stylers/ui_view_styler.rb b/motion/ruby_motion_query/stylers/ui_view_styler.rb index b1bf6ec..9af841e 100644 --- a/motion/ruby_motion_query/stylers/ui_view_styler.rb +++ b/motion/ruby_motion_query/stylers/ui_view_styler.rb @@ -392,6 +392,12 @@ module RubyMotionQuery end def shadow_path ; @view.layer.shadowPath ; end + def user_interaction_enabled=(value) + @view.setUserInteractionEnabled(!!value) + end + def user_interaction_enabled + @view.isUserInteractionEnabled + end # @deprecated - use frame hashs def left=(value) diff --git a/spec/stylers/_ui_view_styler.rb b/spec/stylers/_ui_view_styler.rb index 315a417..2b52872 100644 --- a/spec/stylers/_ui_view_styler.rb +++ b/spec/stylers/_ui_view_styler.rb @@ -50,6 +50,7 @@ class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet st.background_color = color.red st.tint_color = color.blue st.corner_radius = 5 + st.user_interaction_enabled = false # Shadows st.shadow_color = color.gray @@ -336,6 +337,18 @@ describe 'ui_view_styler' do @value.should.be.false end + it "should set user interaction enabled and disabled" do + view = @vc.rmq.append(@view_klass, :ui_view_kitchen_sink).get + + view.isUserInteractionEnabled.should == false + + rmq(view).style do |st| + st.user_interaction_enabled.should == false + st.user_interaction_enabled = true + st.user_interaction_enabled.should == true + end + end + it "should set shadow values" do view = @vc.rmq.append(@view_klass, :ui_view_kitchen_sink).get