In new() for one class(list_box) I'm creating a sub-object from a different class (txt_box) and am passing it a (list_box) method reference called "updt" like this
$self->{txt_box}=txt_box->new( $self->{frm}, sub {$self->updt} );
My problem is that when I call the reference from inside the txt_box object as shown below the supplied argument "$self->{contents}" isn't showing up at all. By contrast if I supply a reference to non-oop sub like this...
$self->{txt_box}=txt_box->new( $self->{frm}, \&test_if_txt_box_content +s_passed_back );
then "$self->{contents}" is passed fine. Here's how I'm calling the references
sub new { my $class = shift; my $self = {}; bless( $self, $class ); +#std line $self->{parent_widg}=shift; $self->{sub_to_call_on_keypress}=shift; <===================LOOK + HERE $self->{contents}=''; $self->{entry}=$self->{parent_widg}->new_ttk__entry( -width => 50, + -textvariable => \$self->{contents}, ); $self->{entry}->g_pack( -expand => 0, -fill => 'x', -side => top) +; #-fill => 'both' globals::new_bindtag('new_tag',$self->{entry},4); Tkx::bind( 'new_tag', "<Key>", [ sub { $self->upon_keypress(@_) }, + Tkx::Ev("%W","%K","%k") ] ); return $self; } #std line sub upon_keypress { #calls the sub/method you supplied...if an ordinar +y sub you supply \&sub_nm if method then just obj->method_nm my ($self, $win, $key_nm, $key_no) = @_; #tick print "in upon_keypress and so far you've got $self->{contents}\n +"; #tick $self->{sub_to_call_on_keypress}->( $self->{contents} ); #bug her +e...$self->{contents} gets passed to ORDINARY SUB but not updt method + <===================LOOK HERE }
I'm just wondering why the method isn't "seeing" that argument. Any help much appreciated.

In reply to unable to call a method reference with an argument by previous

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.