http://www.perlmonks.org?node_id=412750


in reply to right to left Tk text widget

Tricky problem. I threw together some code that *almost* works. Feel free to expand on this. Current bugs I have noticed are:
1) Backspace and delete should be re-mapped to one another (to account for the backwords nature of the writing).
2) Sometime it just plain goofs, and doesn't print letters in the proper (reversed) order. This bug seems to have something to do with using the mouse to change cursor position, but I can't tell for sure.
3) cursor keys will not navigate properly.
#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new( -background=>"darkviolet" ); my $t1 = $mw->Text( -background=>"navy", -foreground=>"white", -height=>35, -width=>80, -wrap=>"word", -selectbackground=>"blueviolet" )->pack; $t1->bind("<KeyRelease>" => sub {$t1->SetCursor('current - 1 chars')}) +; MainLoop;


edit: I think I figured bug 2 out... text is printed out of order if you hit a second key before the first key is released. Unfortunately, switching KeyRelease with KeyPress doesn't make everything work. Text is still sometimes out of order, for no apparant reason.

--
Linux, sci-fi, and Nat Torkington, all at Penguicon 3.0