3

由于某种原因,当我将滑块(比例)添加到弹出菜单时它不起作用。它显示但不动。我怎样才能让滑块工作?只需将其放入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
4

0 回答 0