in reply to Tk hidden binding
This is about all I can figure out. My guess is the \x{13} is the text widget trying to print the line ( which is normal behavior), but the $mw binding is somehow messing it up. If the below setting of the bindtags dosn't help, I would guess you have a defective Tk installation? Can you reinstall Tk? What version of Tk and Perl are you running? Does the following script give good behavior? I left the "test 4" uncommented. Play with it and see what happens. Otherwise, post a self contained complete mini example that demonstrates the problem.
I just diid notice a different behavior for the Text::Undo vs the plain Text widget, and if the widget is Scrolled or not. So you may want to try binding to the REAL text widget, not the Scrolled widget. I noticed with a Scrolled widget, the line gets printed, whearas in the plain widget it does not. Also, can you test your real script with a Scrolled Text instead of a Scrolled TextUndo?
my $t1 = $mw->Scrolled('TextUndo')->pack; my $t1_real = $t1->Subwidget("scrolled");
#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::TextUndo; 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; # uncomment the following sections to get different behavior of the # bindings, the test 4 is left uncommented to start, to show proper be +havior ##################################################### # test 1 # without any Text control s binding, the text widget prints a # line across the text widget AND a "main control s" to the console ################################################### # test 2 #if we just add a control s binding to the text widget # we get main control s, and text control s printed to console, # and a line printed in the text widget #$t1->bind('<Control-s>', sub { print "\ttext control s\n"; }); #################################################### #test 3 # we get only text control s to the console and the line, # but NO main control s #$t1->bind('<Control-s>', sub { print "\t\tfoo\n"; $_[0]->break }); ##################################################### #test 4 # no line is shown, no line printed, no main control s , # just a foo. # # the order of bindtags is: # class name (Tk::Text), window name, ancestral toplevel, "all" # this modifies the tag list so that the instance binding, # which includes a call to break(), has higher priority # than the class binding $t1->bind('<Control-s>', sub { print "\t\tfoo\n"; $_[0]->break }); $t1->bindtags([($t1->bindtags)[1,0,2,3]]); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk hidden binding
by emilbarton (Scribe) on Jul 24, 2011 at 08:21 UTC | |
by zentara (Cardinal) on Jul 24, 2011 at 11:12 UTC | |
by emilbarton (Scribe) on Jul 24, 2011 at 12:56 UTC | |
|
Re^2: Tk hidden binding
by emilbarton (Scribe) on Jul 24, 2011 at 08:35 UTC | |
by zentara (Cardinal) on Jul 24, 2011 at 11:18 UTC |