Your problem description is incomplete insofar as you do not show us test_if_txt_box_contents_passed_back or updt. See How do I post a question effectively?. In particular, creating a self-contained example would be illuminative.

My guess would be that the $self variable you are calling update on in your sub is a different variable than the $self object that contains contents. Think about it this way:

$main_self->{txt_box}=txt_box->new( $main_self->{frm}, sub {$main_self +->updt} ); ... sub new { my $class = shift; my $new_self = {}; bless( $new_self, $c +lass ); #std line $new_self->{parent_widg}=shift; $new_self->{sub_to_call_on_keypress}=shift; <=================== +LOOK HERE $new_self->{contents}=''; $new_self->{entry}=$new_self->{parent_widg}->new_ttk__entry( -widt +h => 50, -textvariable => \$new_self->{contents}, ); $new_self->{entry}->g_pack( -expand => 0, -fill => 'x', -side => +top); #-fill => 'both' globals::new_bindtag('new_tag',$new_self->{entry},4); Tkx::bind( 'new_tag', "<Key>", [ sub { $new_self->upon_keypress(@_ +) }, Tkx::Ev("%W","%K","%k") ] ); return $new_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 ($new_self, $win, $key_nm, $key_no) = @_; #tick print "in upon_keypress and so far you've got $new_self->{contents +}\n "; #tick $new_self->{sub_to_call_on_keypress}->( $new_self->{contents} ); +#bug here...$self->{contents} gets passed to ORDINARY SUB but not upd +t method <===================LOOK HERE }
Your keypress routine uses $main_self in what is passed, not $new_self that has the contents field.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: unable to call a method reference with an argument by kennethk
in thread 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.