Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^2: right to left Tk text widget by wolfger
in thread right to left Tk text widget by davidj

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-05-28 06:24 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (98 votes). Check out past polls.