Menu.append_check_item(), like Menu.append(), is supposed to return a reference to the created menu item. Here is a test code which seems to show that this behavior works for append(), but fails for append_check_item(). This is the output I get: % ruby test-menu.rb #<Wx::MenuItem:0xb74c036c> nil Am I missing something or is this a bug? Both menu items are created and work as expected. I am running the 1.9.2 tarball. #!/usr/bin/env ruby begin require ''wx'' rescue LoadError => no_wx_err begin require ''rubygems'' load ''wx'' rescue raise no_wx_err end end include Wx class MinimalFrame < Wx::Frame def initialize(title) # The main application frame has no parent (nil) super(nil, :title => title, :size => [ 700, 400 ]) menu_bar = Wx::MenuBar.new menu_file = Wx::Menu.new item1 = menu_file.append(1000, "Test Item 1") item2 = menu_file.append_check_item(1001, "Test Checked Item") puts item1 puts item2 menu_bar.append(menu_file, "Test1") self.menu_bar = menu_bar end end Wx::App.run do self.app_name = ''Minimal'' frame = MinimalFrame.new("Minimal wxRuby App") frame.show end Thanks, Bob _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Robert Anderson wrote:> Menu.append_check_item(), like Menu.append(), is supposed to return a > reference to the created menu item. Here is a test code which seems > to show that this behavior works for append(), but fails for > append_check_item(). This is the output I get: > > % ruby test-menu.rb > #<Wx::MenuItem:0xb74c036c> > nil > > Am I missing something or is this a bug? Both menu items are created > and work as expected. I am running the 1.9.2 tarball.Thank you for the report and the clear test-case. It''s a bug; the wrong C++ method signature was in one of the header files from which the API is generated. It''s now fixed by SVN:1486 for the next release. If you need to work around n the interim, you should can use the long form of append_item and give Wx::ITEM_CHECK as the fourth parameter. cheers alex
Robert Anderson
2008-Jan-04 21:37 UTC
[wxruby-users] problem with Menu.append_check_item()
On Jan 4, 2008 1:02 PM, Alex Fenton <alex at pressure.to> wrote:> Robert Anderson wrote: > > Menu.append_check_item(), like Menu.append(), is supposed to return a > > reference to the created menu item. Here is a test code which seems > > to show that this behavior works for append(), but fails for > > append_check_item(). This is the output I get: > > > > % ruby test-menu.rb > > #<Wx::MenuItem:0xb74c036c> > > nil > > > > Am I missing something or is this a bug? Both menu items are created > > and work as expected. I am running the 1.9.2 tarball. > > Thank you for the report and the clear test-case. It''s a bug; the wrong > C++ method signature was in one of the header files from which the API > is generated. > > It''s now fixed by SVN:1486 for the next release. If you need to work > around n the interim, you should can use the long form of append_item > and give Wx::ITEM_CHECK as the fourth parameter. > > cheers > alex >Beautiful. Thanks for the confirmation, fix, and work-around. Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080104/8e3e8f87/attachment-0001.html
Possibly Parallel Threads
- Issues adding sub-menu items
- [720] trunk/wxruby2/doc/textile/menu.txtl: Update, rubyify and tidy
- [724] trunk/wxruby2: Initial commit of HtmlWindow functionality
- [903] branches/wxruby2/wxwidgets_282/samples: Added #!/usr/bin/env ruby to the grid sample.
- Adding more sugar to wxSugar