Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: right to left Tk text widget

by wolfger (Deacon)
on Dec 07, 2004 at 14:26 UTC ( [id://412909]=note: print w/replies, xml ) Need Help??


in reply to Re: right to left Tk text widget
in thread right to left Tk text widget

Okay, I got it working better, but it's still buggy. I fixed the bug that prevented cursor keys from working. Also, delete and backspace function normally now (without causing undue cursor movement), although backspace still goes left rather than right, and vice versa. The proper text direction is more reliable, but still committing errors. When I type "This is a test.", I invariably wind up with " .tseta si sihT". The cursor fails to move left on the space following the "a" every single time I type that sentence. If somebody can figure this out, I'd be grateful, as I am now quite interested in solving this problem.
#!/usr/bin/perl use strict; use warnings; use Tk; my $last=1.0; 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("<Key>" => \&rtl); #$t1->bind("<KeyRelease>" => sub {$t1->SetCursor('insert - 1 chars')}) +; sub rtl { my $size = $t1->index('end - 1 chars'); if ($last < $size) { $t1->SetCursor('insert - 1 chars'); } $last = $size; } MainLoop;

edit: Got it! This error occurs on the 10th character of the line, and repeats at the 100th. Our comparison is saying that 1.9 is not less than 1.10 and 1.99 is not less than 1.100. True for integers, but not for line.word count.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://412909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found