http://qs321.pair.com?node_id=1129316


in reply to Different behavior for Moo and Moose with Wx?

The problem is obvious, the class should be MyMenuBar not Wx::MenuBar, but with Wx::StatusBar is all OK, what I'm doing wrong?

I get the same problem with Moo 1.006001 and Moo-2.000001

I think its a bug in Moo but I'm not confident in that

In addition, you're confused, your class is called MenuBar::Item but it extends 'Wx::Menu' not a Wx::MenuItem

  • Comment on Re: Different behavior for Moo and Moose with Wx?

Replies are listed 'Best First'.
Re^2: Different behavior for Moo and Moose with Wx?
by stefbv (Curate) on Jun 07, 2015 at 08:04 UTC

    Thanks for the feedback, unfortunately fixing the extended class name does not solve the problem :(

      Thanks for the feedback, unfortunately fixing the extended class name does not solve the problem :(

      Well, not surprising, fixing thinkos rarely fixes "bugs" :)

      Well, it might be considered a bug that Moo isn't as helpful as Moose, Moose actually checks the class is blessed into the right, Moo doesn't

      Quick workaround is

      sub MenuBar::Item::BUILD { my $self = shift; bless $self, __PACKAGE__ ; $self->Append( $self->item_quit ); return $self; }

      Now why doesn't Wx::Menu obey the common rules of subclassing/inheritance, well not all things in wxPerl are mean to be subclasses, and indeed menu/menubar are indeed odd candidates for that ... some of this is explained in Re: wxperl-users scalar reference objects?

      As you can see a Wx::Menu isn't a hashref, its a scalar ref

      FWIW, not everything needs to be subclasses, ex wxperl_usage

        Thank you, for the explanations. I'm following the "not everything needs to be subclasses" path.

        P.S.: I didn't really think that changing 'Wx::Menu' to 'Wx::MenuItem' will fix the problem :)