diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 089ceca..2c5caf0 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -98,6 +98,10 @@ class MainController < UIViewController rmq.append(UIButton, :present_button).on(:touch_up) do rmq.view_controller.presentModalViewController(PresentedController.new, animated:true) end + + rmq.append(UIButton, :debounce_button).on(:tap, debounce: 1) do + puts "I can only be pressed every second." + end end def init_popup_section diff --git a/app/stylesheets/main_controller_stylesheet.rb b/app/stylesheets/main_controller_stylesheet.rb index e3925b9..747cf32 100644 --- a/app/stylesheets/main_controller_stylesheet.rb +++ b/app/stylesheets/main_controller_stylesheet.rb @@ -62,7 +62,14 @@ class MainControllerStylesheet < ApplicationStylesheet button_set_button st st.background_color = color.purple st.font = font.small - st.text = 'Present controller' + st.text = 'Present Controller' + end + + def debounce_button(st) + button_set_button st + st.background_color = color.battleship_gray + st.font = font.small + st.text = "Debounce Button" end def section(st) diff --git a/motion/ruby_motion_query/event.rb b/motion/ruby_motion_query/event.rb index 4a57a9a..91eca6a 100644 --- a/motion/ruby_motion_query/event.rb +++ b/motion/ruby_motion_query/event.rb @@ -47,6 +47,11 @@ module RubyMotionQuery end def set_options(opts) + if opts[:debounce] + @debounce_length = opts[:debounce] + @debounce_stamp = Time.now + end + if gesture? @recognizer.tap do |o| o.cancelsTouchesInView = opts[:cancels_touches_in_view] if opts.include?(:cancels_touches_in_view) @@ -73,13 +78,8 @@ module RubyMotionQuery opts[:init].call(@recognizer) end end - else - if opts[:debounce] - @debounce_length = opts[:debounce] - @debounce_stamp = Time.now - end end - end + end #set_options def gesture? @gesture