fixed debounce code and added example button to app

This commit is contained in:
Gant
2015-04-06 23:12:38 -05:00
parent c28f7d1413
commit 6cce970946
3 changed files with 18 additions and 7 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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