Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 1205
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: UlGoebel [...] compuserve.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Perl Tk; Text-widget; there: the "insert"-method
Dear developer, I use Perl, v5.6.1, "perl -v" gives: This is perl, v5.6.1 built for i586-linux which came with my SuSS Linux 7.3; uname -a gives Linux linux 2.4.10-4GB #1 Tue Sep 25 12:33:54 GMT 2001 i586 unknown I have a problem, which might be a bug, but I am not sure: With Perl Tk I made a Text widget, bound a callback to a keystroke, which should insert a special character in the text. The insertion works, but it has a side effect, which could be the bug, where I am talking about: The text from the insert-cursor to the end of the line is deleted. The script contains the following code: $HF = MainWindow -> new; $Text = $HF -> Scrolled ('Text', -scrollbars => 'se') -> pack (-side => "bottom"); $Text -> bin ("<Control-k>", \&Taste); sub Taste { $Text -> insert ("insert", "X"); } As I wrote, the insertion works, but the rest of the line is being deleted. If there are no more characters on the line behind the insert-cursor, the EOL is deleted and the next line comes up. For experiment, I used "1.5" instead of "insert" as insert-position in the insert-method: sub Taste { $Text -> insert ("1.5", "X"); } That makes the insertion at this position, and then deletes the rest of the line behind the insert-cursor on its actual position. Can You help me? By the way, in future not the "X" has to be inserted, but the backslash. I am writing my own editor, which inserts spcial characters for TEX-scripts ("\", "{", "}", "[", "]") by the keystrokes Ctrl-k, Ctrl-u, Ctrl-p, Ctrl-i and Ctrl-o. That makes it easyer to write fast without looking at the keyboard. Many thanks, Your Ulrich Goebel
From: Ulrich Goebel <UlGoebel [...] compuserve.de>
To: bug-Tk [...] rt.cpan.org
Subject: Re: [cpan #1205]
Date: Thu, 25 Jul 2002 09:27:05 +0200
... the interesting side effect doesn't happen, since I bound the sub Taste to "<Alt-k>" instead of "<Control-k>" -- Ulrich Goebel Glockengarten 70 44803 Bochum
From: Jack Dunnigan
[guest - Fri Jun 28 08:54:48 2002]: Show quoted text
> Dear developer, > > I use Perl, v5.6.1, "perl -v" gives: > This is perl, v5.6.1 built for i586-linux > > which came with my SuSS Linux 7.3; uname -a gives > Linux linux 2.4.10-4GB #1 Tue Sep 25 12:33:54 GMT 2001 i586 unknown > > I have a problem, which might be a bug, but I am not sure: > > With Perl Tk I made a Text widget, bound a callback to a keystroke, > which > should insert a special character in the text. The insertion works, > but it > has a side effect, which could be the bug, where I am talking about: > The text from the insert-cursor to the end of the line is deleted. > > The script contains the following code: > > $HF = MainWindow -> new; > $Text = $HF -> Scrolled ('Text', -scrollbars => 'se') > -> pack (-side => "bottom"); > $Text -> bin ("<Control-k>", \&Taste); > sub Taste { $Text -> insert ("insert", "X"); } > > As I wrote, the insertion works, but the rest of the line is being > deleted. If there are no more characters on the line behind the > insert-cursor, the EOL is deleted and the next line comes up. For > experiment, I used "1.5" instead of "insert" as insert-position in > the insert-method: > > sub Taste { $Text -> insert ("1.5", "X"); } > > That makes the insertion at this position, and then deletes the rest > of the line behind the insert-cursor on its actual position. > > Can You help me? > > By the way, in future not the "X" has to be inserted, but the > backslash. I am writing my own editor, which inserts spcial > characters for TEX-scripts ("\", "{", "}", "[", "]") by the > keystrokes Ctrl-k, > Ctrl-u, Ctrl-p, Ctrl-i and Ctrl-o. That makes it easyer to write fast > without looking at the keyboard. >
The Text widget is doing exactly what is documented. i.e. Invoking it's class binding. From the docs: "Control-k deletes from the insertion cursor to the end of its line; if the insertion cursor is already at the end of a line, then Control- k deletes the newline character." To learn more, look at 'bindtags' - however, this ticket can be closed!
As you have presumably found out by now <control-k> has a class binding for delete-to-end-of-line. See the ->bind calls in Tk::Text's Text.pm This is called after your callback.