Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How can I call a class method of the object's parent class?

by dsheroh (Prior)
on Jan 03, 2018 at 10:24 UTC ( #1206591=note: print w/replies, xml ) Need Help??


in reply to How can I call a class method of the object's parent class?

I took a quick look at the source on metacpan and, after a couple minutes of "that really should work!", I spotted it: There are two packages in Popupmenu.pm.

You're using Curses::UI::Popupmenu, which is the second class defined in the source file. Its only parent class is Curses::UI::Widget.

The class you want is Curses::UI::PopupmenuListbox, which has two parents, Curses::UI::Listbox and Curses::UI::Window.

Replies are listed 'Best First'.
Re^2: How can I call a class method of the object's parent class?
by dissident (Sexton) on Jan 03, 2018 at 22:22 UTC

    Thank you very much for looking into this!

    Yes, the thing that this class is actually two packages confused me very much.

    Both have different class methods. I followed just the documentation which does not indicate anything about this mixed inheritance, and only tells about using Curses::UI::Popupmenu.

    What I am still not understanding how to solve correctly is:

    Using the class Curses::UI::PopupmenuListbox does not work, because this class/object is generated/used by Curses::UI::Popupmenu itself, when the dropdown box is to actually be opened/painted.

    The object that the application gets with the Popupmenu->new() method is of class Popupmenu, with completely different inheritances than those of PopupmenuListbox class. Thus, if I understand correctly, I have no way to call the PopupmenuListbox methods using the object of class Popupmenu I got.

    I have the impression that it is not intended that the application itself deals with the PopupmenuListbox class, which in my impression the author intended to encapsulate from the application.

    Thus, thinking about it, I now ask myself whether the correct approach could maybe to implement a Popupmenu class method set_selection(), which can then encapsulate the PopupmenuListbox handling from the application?

      Just in case somebody with the same problem finds this thread, here is the method function I added to Popupmenu.pm to solve the problem:
      sub set() { my $this = shift; my $id = shift; $this->{-values}->[$this->{-selected}] = $id; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1206591]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2018-04-22 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?