# Problem with Menu.append\_check\_item()

**URL:** <https://www.ruby-forum.com/t/problem-with-menu-append-check-item/125052>\
**Category:** wxRuby\
**Created:** [January 4, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/problem-with-menu-append-check-item/125052 "2008-01-04T21:25:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 4, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/problem-with-menu-append-check-item/125052/1 "2008-01-04T21:25:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 4, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/problem-with-menu-append-check-item/125052/2 "2008-01-04T22:06:06Z")

</div>

Robert A. wrote:

> 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

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 4, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/problem-with-menu-append-check-item/125052/3 "2008-01-04T22:41:23Z")

</div>

On Jan 4, 2008 1:02 PM, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Am I missing something or is this a bug? Both menu items are created  
> > cheers  
> > alex

Beautiful. Thanks for the confirmation, fix, and work-around.

Bob
