Forum: wxRuby Menu.delete returned "wrong # of argument" on Mac

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01a68e65c05c8751d75dbf957ea4fa23?d=identicon&s=25 Zhimin Zhan (zzhan)
on 2009-01-20 12:38
Hi,

I was trying to delete menu items in a submenu, the code worked fine on
Windows, but failed on Mac.

I modified the sample bigdemo/wxMenu.rbw,

  def menu_101(event)
       @log.write_text("Welcome to Mercury")
       # New here, change submenu to @submenu in initialize()
       @submenu.get_menu_items.each do |menu_item|
            @submenu.delete(menu_item)
         end
   end

Error:
wxMenu.rbw:140:in `delete': Wrong arguments for overloaded method
'wxMenu.Delete'. (ArgumentError)
Possible C/C++ prototypes are:
    void wxMenu.Delete(int id)
    void wxMenu.Delete(wxMenuItem *item)


wxRuby 1.9.9
Platform: Mac OS X

Thanks,
Zhimin
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-01-23 13:30
(Received via mailing list)
Hi Zhimin

Zhimin Zhan wrote:
>          end
>    end
>
> Error:
> wxMenu.rbw:140:in `delete': Wrong arguments for overloaded method
> 'wxMenu.Delete'. (ArgumentError)
> Possible C/C++ prototypes are:
>     void wxMenu.Delete(int id)
>     void wxMenu.Delete(wxMenuItem *item)
>

Thanks for the report and sample code. I tried this out with 1.9.9 and I
get an error (although a slightly different one).

I tried it with SVN HEAD (with ruby 1.8.6 and 1.9.1) and it works
correctly, no error is raised. I believe it may have been fixed by a
change I applied following this previous thread, so that MenuItems are
correctly preserved from GC:

http://rubyforge.org/pipermail/wxruby-users/2009-J...

So the problem should already be resolved by the next release.

thanks again
alex
This topic is locked and can not be replied to.