mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-01-12 09:33:43 +08:00
fixed debounce code and added example button to app
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user