class Fidgit::Slider::Handle

@private

Public Class Methods

new(options = {}, &block) click to toggle source

@param (see Element#initialize)

@option (see Element#initialize)

Calls superclass method Fidgit::Element::new
# File lib/fidgit/elements/slider.rb, line 16
def initialize(options = {}, &block)
  options = {
    background_color: default(:background_color),
    border_color: default(:border_color),
  }.merge! options

  super options

  subscribe :begin_drag do |sender, x, y|
    # Store position of the handle when it starts to drag.
    @drag_start_pos = [x - self.x, y - self.y]
  end

  subscribe :update_drag do |sender, x, y|
    if parent.enabled?
      parent.handle_dragged_to x - @drag_start_pos[0], y - @drag_start_pos[1]
    else
      publish :end_drag
    end
  end

  subscribe :end_drag do
    @drag_start_pos = nil
  end
end

Public Instance Methods

drag?(button) click to toggle source
# File lib/fidgit/elements/slider.rb, line 11
def drag?(button); button == :left; end
tip() click to toggle source
# File lib/fidgit/elements/slider.rb, line 42
def tip; parent.tip; end