Courage has asked for the wisdom of the Perl Monks concerning the following question:

Dear wise fellows perlmonks!

How can one intercept changing of cursor position in Text widget?
Is there a way to do this without intercepting of all events and comparing old and new position?

Thanks in advance,
Courage, the Cowardly Dog.
PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

Replies are listed 'Best First'.
Re: Tk question about Text widget
by Courage (Parson) on Jun 08, 2002 at 14:11 UTC
    After some experiments and Text.pm reading I found out a way to do this
    Seems like "good" way of doing this is unimplemented (so question is still remains, whether exists this "good" way), but there is "not such bad" way.

    In my widget, which is derived from Tk::Text, I redefined a function SetCursor, and all worked!

    sub SetCursor { my $w = shift; print STDERR "here we know that cursor position changed\n"; my $rc = $w->SUPER::SetCursor(@_); print STDERR "do something more when Text widget calmed down after c +hanging cursor position\n"; return $rc; }
    Works okay, any cursor changes are reported.
    Blessed OOP in Tk!

    Also, many other intresting event mappings could be done this way.

    Courage, the Cowardly Dog.
    PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.