Automatically call subroutine when cursor position changes in text widget

I am using a module Tk::Text.

I want that whenever the user changes the position of the cursor inside the module Tk::Text, he must act as a trigger to call the routine I wrote.

How do I implement this?

EDIT:

As Donal Fellows replied, I somehow need to find if the sign insertchanges when I call the procedure markSet. I searched the web extensively to find a solution to this problem, but to no avail. Now I need you guys to help me with this. Thank!

+4
source share
2 answers

insert ( ), markSet. , -, , , insert, ? (, Tcl/Tk, , Perl- , , , ?)

+2

, fooobar.com/questions/1531356/..., . http://p3rl.org/perlobj http://p3rl.org/Tk::Widget http://p3rl.org/require

#!/usr/bin/perl --
use strict; use warnings;
use Tk;
Main( @ARGV );
exit( 0 );

BEGIN {
    package Tk::TText;
    $INC{q{Tk/TText.pm}}=__FILE__;
    use parent qw[ Tk::Text ];
    Tk::Widget->Construct( q{TText} );
    sub markSet {
        warn qq{@_};
        my( $self, @args ) = @_;
        $self->SUPER::markSet( @args );
    }
}

sub Main {
    my $mw = tkinit();
    $mw->TText->pack;
    use Tk::WidgetDump; $mw->WidgetDump; ## helps you Tk your Tk
    $mw->MainLoop;
}
__END__
Tk::TText=HASH(0x10f7a74) insert @347,218 at - line 13.
Tk::TText=HASH(0x10f7a74) anchor insert at - line 13.
+1

Source: https://habr.com/ru/post/1531356/


All Articles