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}, sub {$self->updt} );
then "$self->{contents}" is passed fine. Here's how I'm calling the references$self->{txt_box}=txt_box->new( $self->{frm}, \&test_if_txt_box_content +s_passed_back );
I'm just wondering why the method isn't "seeing" that argument. Any help much appreciated.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 }
In reply to unable to call a method reference with an argument by previous
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |