让gtk滑块在弹出菜单中工作?

时间:2013-11-13 00:29:38

标签: ruby gtk3

出于某种原因,当我向弹出菜单添加滑块(缩放)时,它不起作用。它显示但不移动。如何让滑块工作?只需将其放在Gtk::Window

require 'gtk3' #gtk2 will probably work 

class VolumeButton <  Gtk::Button
  def initialize
    super()
    @theme = Gtk::IconTheme.default
    self.image = Gtk::Image.new(@theme.load_icon("audio-volume-high", 16, :force_svg))
    @menu = Gtk::Menu.new
    @menu.width_request = 200
    @item = Gtk::MenuItem.new
    @slider = Gtk::Scale.new(:horizontal, 0, 100, 1)
    @item.add(@slider)
    @menu.append(@item)
    @menu.show_all # this makes it show
    self.signal_connect "button-release-event" do |widget, event|
      @menu.popup(nil, nil, event.button, event.time)
    end
  end
end

0 个答案:

没有答案