Removes the handlers associated with a component for the duration of the block. All handlers are re-added to the component afterwards.
some_text_field.disable_handlers(:action, :key) do # some code that we don't want to trigger action listener methods or key listener methods for end
# File lib/monkeybars/view.rb, line 584 def disable_handlers(*types) types.map! { |t| t.camelize } listeners = {} types.each do |type| listener_class = if Monkeybars::Handlers::AWT_TYPES.member?(type) instance_eval("java.awt.event.#{type}Listener", __FILE__, __LINE__) elsif Monkeybars::Handlers::SWING_TYPES.member?(type) instance_eval("javax.swing.event.#{type}Listener", __FILE__, __LINE__) elsif Monkeybars::Handlers::BEAN_TYPES.member?(type) instance_eval("java.beans.#{type}Listener", __FILE__, __LINE__) end listeners[type] = self.get_listeners(listener_class.java_class) listeners[type].each do |listener| self.send("remove#{type}Listener", listener) end end yield types.each do |type| listeners[type].each do |listener| self.send("add#{type}Listener", listener) end end end
Generated with the Darkfish Rdoc Generator 2.