[wxruby-users] Crash in evt_menu

Alex Fenton alex at pressure.to
Wed Jul 30 10:53:05 EDT 2008


Eric Rubin wrote:
>
> I’m trying to create a TaskBarIcon with a right-click menu but I get a 
> crash (in the evt_menu call) as soon as I right-click on the icon.
>
> Here’s the error message:
>
> C:/Projects/SoftPhone1/lib/SoftPhone.rb:35:in `process_event': Swig 
> director type mismatch in output value of type 'wxMenu *' (TypeError)
>
I agree it's not the most clear error message. What's it telling you is 
that the method create_popup_menu is expected to return a value of type 
Wx::Menu, but you're not doing this.

In SWIG's terminology, "director" methods are those, like 
create_popup_menu, where a ruby method is called on a certain event 
happening (in this case, right-clicking the icon) and you need to return 
a particular type (in this case, a Wx::Menu to be shown.
>
> (The rescue doesn’t catch the error).
>
> Here’s the code (it doesn’t matter which variant of the evt_menu call 
> I use):
>
> class SysTrayIcon < TaskBarIcon
>
> def initialize(parent)
>
> super()
>
> @softPhone = parent # soft_phone_frame
>
> icon = Icon.new("icons/phone.ico", BITMAP_TYPE_ICO)
>
> set_icon(icon, "Valcom VIP Page")
>
> end
>
> def create_popup_menu
>
> menu = Menu.new
>
> close_item = menu.append(101, 'Close VIP-Page', 'Close VIP-Page')
>
> evt_menu(close_item, :on_close)
>
# add this here, and delete the rescue clause
return menu
>
> end
>
> def on_close(event)
>
> @softphone.exit
>
> end
>
> end
>

cheers
alex


More information about the wxruby-users mailing list