From: Stephen D. <st...@da...> - 2002-09-17 17:08:39
|
On Mon, 16 Sep 2002, Takaaki Tateishi wrote: > At Sun, 15 Sep 2002 23:36:57 +0100 (BST), > > Can anyone point me at an example of pop-up menus done in ruby-fltk (or > > fltk-proper for that matter). > > This is to implement a right-click context-sensitive menu. > > Use FLTK::MenuButton with the type POPUP3. Here is an example: > > require 'fltk' > > $items1 = [ > ["item1", 0, proc{ print("item1\n") }, "item1_data", FLTK::SUBMENU], > ["bar", 0, proc{|w,data| print("item1/bar\n") }, "item1_foo_data"], > [], > ["item2", 0, proc{ print("item2\n") }, "item2_data", FLTK::SUBMENU], > ["foo", 0, proc{ print("item2/foo\n") }, "item2_foo_data"], > [], > ["item3", 0, proc{ print("item3\n") }, "item3_data", FLTK::SUBMENU], > ["foo", 0, proc{ print("item3/foo\n") }, "item3_foo_data"], > [], > ] > > FLTK::Window.new(300,100){|win| > mb = FLTK::MenuButton.new(0,0,100,100,"popup") > mb.menu($items1) > mb.widget_type(FLTK::MenuButton::POPUP3) > win.show > } > > FLTK.run Hi Takaaki, Thanks for the pointer and the example. It isn't my first choice to have an actual screen widget - I'm looking to construct and pop-up a custom menu from my custom widget's handle method. Is there a way to have the MenuButton widget created but not actually mapped on the window? And then just use menubutton.popup when I want to show it? I will tinker some on my own and see what I come up with. Once only slightly connected question - is there a way to make the arrows for sub-menus a little more subtle? Thanks, Steve |