balee has asked for the wisdom of the Perl Monks concerning the following question:
I try to make a simple statusbar, to show current cursor position in text widget.
Problem_1: it only works with the mousebutton. - I want to use the cursor buttons also in keyboard. So maybe it is not good to bind with mouse, it would be better to get the insertion cursor position. How?
Problem_2:I would like to use LineNumberText instead of Text, but current position doesn't work, it gives back '8'. I don't understand why.
Here is my little testscript:I appreciate any help!use Tk; use Tk::LineNumberText; $mw = MainWindow->new; $t = $mw->Text()->pack(); #$t = $mw->LineNumberText('Text')->pack(); $t->insert('end', "This is some\n"); $t->insert('end', "normal text\n"); $t->bind('<Button-1>' => [\&updateStatus]); MainLoop(); sub updateStatus { $status = $t->index('current'); print "$status\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cursor position in text widget and linenumbertext
by liverpole (Monsignor) on Sep 15, 2009 at 14:22 UTC | |
by balee (Novice) on Sep 15, 2009 at 20:50 UTC | |
by lamprecht (Friar) on Sep 15, 2009 at 21:45 UTC |