Methods
C
D
E
I
N
S
Constants
DEFAULT_FOREGROUND = 'black'
 
DEFAULT_BACKGROUND = 'white'
 
DEFAULT_INTERVAL = 750
 
Class Public methods
new(parent=nil, keys={})
# File ext/tk/sample/tkballoonhelp.rb, line 46
def initialize(parent=nil, keys={})
  @parent = parent || Tk.root

  @frame = TkToplevel.new(@parent)
  @frame.withdraw
  @frame.overrideredirect(true)
  @frame.transient(TkWinfo.toplevel(@parent))
  @epath = @frame.path

  if keys
    keys = _symbolkey2str(keys)
  else
    keys = {}
  end

  @command = keys.delete('command')

  @interval = keys.delete('interval'){DEFAULT_INTERVAL}
  _balloon_binding(@interval)

  # @label = TkLabel.new(@frame, 'background'=>'bisque').pack
  @label = TkLabel.new(@frame,
                       'foreground'=>DEFAULT_FOREGROUND,
                       'background'=>DEFAULT_BACKGROUND).pack
  @label.configure(_symbolkey2str(keys)) unless keys.empty?
  @path = @label
end
Instance Public methods
command(cmd = Proc.new)
# File ext/tk/sample/tkballoonhelp.rb, line 86
def command(cmd = Proc.new)
  @command = cmd
  self
end
destroy()
# File ext/tk/sample/tkballoonhelp.rb, line 135
def destroy
  @frame.destroy
end
epath()
# File ext/tk/sample/tkballoonhelp.rb, line 74
def epath
  @epath
end
erase()
# File ext/tk/sample/tkballoonhelp.rb, line 126
def erase
  begin
    @parent.configure('cursor', @org_cursor)
  rescue
    @parent.cursor(@org_cursor)
  end
  @frame.withdraw
end
interval(val)
# File ext/tk/sample/tkballoonhelp.rb, line 78
def interval(val)
  if val
    @timer.interval(val)
  else
    @interval
  end
end
show()
# File ext/tk/sample/tkballoonhelp.rb, line 91
def show
  x = TkWinfo.pointerx(@parent)
  y = TkWinfo.pointery(@parent)
  @frame.geometry("+#{x+1}+#{y+1}")

  if @command
    case @command.arity
    when 0
      @command.call
    when 2
      @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent))
    when 3
      @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
                    self)
    else
      @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
                    self, @parent)
    end
  end

  @frame.deiconify
  @frame.raise

  begin
    @org_cursor = @parent.cget('cursor')
  rescue
    @org_cursor = @parent['cursor']
  end
  begin
    @parent.configure('cursor', 'crosshair')
  rescue
    @parent.cursor('crosshair')
  end
end