set_msg

set_msg(x, y, bhelp, parent)
Instance Public methods
# CASE1 : command takes no arguemnt
bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
                         :relief=>:ridge, :background=>'white',
                         :command=>proc{
                           y = TkWinfo.pointery(sb) - TkWinfo.rooty(sb)
                           bh.text "current index == #{sb.nearest(y)}"
                         })

# CASE2 : command takes 2 arguemnts
bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
                         :relief=>:ridge, :background=>'white',
                         :command=>proc{|x, y|
                           bh.text "current index == #{sb.nearest(y)}"
                         })

# CASE3 : command takes 3 arguemnts
Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
                    :relief=>:ridge, :background=>'white',
                    :command=>proc{|x, y, bhelp|
                      bhelp.text "current index == #{sb.nearest(y)}"
                    })

# CASE4a : command is a Proc object and takes 4 arguemnts
cmd = proc{|x, y, bhelp, parent|
  bhelp.text "current index == #{parent.nearest(y)}"
}

Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
                    :relief=>:ridge, :background=>'white',
                    :command=>cmd)

sb2 = TkScrollbox.new.pack(:fill=>:x)
sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
                    :padx=>5, :relief=>:raised,
                    :background=>'gray25', :foreground=>'white',
                    :command=>cmd)

#=begin # CASE4b : command is a Method object and takes 4 arguemnts

doc_ruby_on_rails
2015-04-24 04:29:01
Comments
Leave a Comment

Please login to continue.