Sha256: f4b50df0a087bef232ab7318436d6a3f60eabf8541d2a3573b9b246816f23e62

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

module Rabbit
  module Renderer
    module Display
      module HookHandler
        def initialize(*args, &block)
          super
          init_hook_handler
        end

        def call_hook_procs(procs, *args)
          procs.any? {|proc| proc.call(*args)}
        end

        def add_motion_notify_hook(hook=nil, &block)
          hook ||= Proc.new(&block)
          @motion_notify_hook_procs << hook
        end

        def clear_motion_notify_hook
          @motion_notify_hook_procs.clear
        end

        def add_scroll_hook(hook=nil, &block)
          hook ||= Proc.new(&block)
          @scroll_hook_procs << hook
        end

        def clear_scroll_hook
          @scroll_hook_procs.clear
        end

        def add_button_press_hook(hook=nil, &block)
          hook ||= Proc.new(&block)
          @button_press_hook_procs << hook
        end

        def clear_button_press_hook
          @button_press_hook_procs.clear
        end

        def add_button_release_hook(hook=nil, &block)
          hook ||= Proc.new(&block)
          @button_release_hook_procs << hook
        end

        def clear_button_release_hook
          @button_release_hook_procs.clear
        end

        def clear_hooks
          init_hook_handler
        end

        private
        def init_hook_handler
          @motion_notify_hook_procs = []
          @scroll_hook_procs = []
          @button_press_hook_procs = []
          @button_release_hook_procs = []
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rabbit-3.0.3 lib/rabbit/renderer/display/hook-handler.rb
rabbit-3.0.2 lib/rabbit/renderer/display/hook-handler.rb
rabbit-3.0.1 lib/rabbit/renderer/display/hook-handler.rb
rabbit-3.0.0 lib/rabbit/renderer/display/hook-handler.rb