Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I would think that your newline is replaced by \x{13} in my Tk version. But why should a newline be printed anyway?

This brings up a good point, what do YOU expect to happen when you press a <control s> in the TextUndo widget? The normal behavior, on my Tk ( version Tk-804.029_500 ) , with no extra bindings associated with it, is to print what appears to be an underscore line segment, not a newline. It is not a dash or hyphen. Repeated presses of <control s> create a continuous line looking like an underscore (at the bottom of the font area).

Do you want this behaviour?

If you want to stop all text insertion, with a <control s>, try this and see what happens. I get NO insertion of any kind into the TextUndo widget. Notice I'm getting the REAL widget, not the Scrolled one.

#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::TextUndo; # a <control s> in the TextUndo widget produces # nothing in the Text area, and a foo to the console my $mw = tkinit; # create a top bar for testing pure $mw focus my $button = $mw->Button(-text=>'test')->pack(); $mw->bind('<Control-s>', sub { print "main control s \n" }); my $t = $mw->Scrolled ('TextUndo')->pack; my $t1 = $t->Subwidget("scrolled"); # get real widget $t1->bind('<Control-s>', sub { print "\t\tfoo\n"; $_[0]->break }); $t1->bindtags([($t1->bindtags)[1,0,2,3]]); MainLoop;

To address the point that you saw no difference in binding to a Scrolled or standard TextUndo widget, notice the difference in behavior in this script, where I bind to the Scrolled widget. I get the foo to the console, plus the underscore line gets printed to the TextUndo.

#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::TextUndo; # when binding to the Scrolled widget, instead # of the real widget, a line gets printed to the text area # as well as the foo to the console my $mw = tkinit; # create a top bar for testing pure $mw focus my $button = $mw->Button(-text=>'test')->pack(); $mw->bind('<Control-s>', sub { print "main control s \n" }); my $t1 = $mw->Scrolled ('TextUndo')->pack; $t1->bind('<Control-s>', sub { print "\t\tfoo\n"; $_[0]->break }); $t1->bindtags([($t1->bindtags)[1,0,2,3]]); MainLoop;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re^3: Tk hidden binding by zentara
in thread Tk hidden binding by emilbarton

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-18 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found