preventing accelerators from inserting into text widget
  Home FAQ Contact Sign in
comp.lang.perl.tk only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.perl.tk Profile…
 Up
preventing accelerators from inserting into text widget         


Author: fossildoc
Date: Feb 27, 2008 22:42

I use a ctrl-s accelerator to save the contents of a text widget, but
I can't prevent the ctrl-s character from inserting into the text. How
can I do this?
5 Comments
Re: preventing accelerators from inserting into text widget         


Author: Ch Lamprecht
Date: Feb 28, 2008 00:03

fossildoc wrote:
> I use a ctrl-s accelerator to save the contents of a text widget, but
> I can't prevent the ctrl-s character from inserting into the text. How
> can I do this?

use strict;
use warnings;

use Tk;
my $mw = tkinit;
my $t = $mw->Text->pack;
$t->bindtags(['MyTag',$t->bindtags]);
$mw->bind('MyTag', '', \&save);

MainLoop;

sub save{
print "saving\n";
Tk::break;
}

HTH, Christoph
Show full article (0.72Kb)
no comments
Re: preventing accelerators from inserting into text widget         


Author: fossildoc
Date: Mar 30, 2008 18:02

On Feb 28, 4:03 am, Ch Lamprecht wrote:
> fossildoc wrote:
>> I use a ctrl-s accelerator to save the contents of a text widget, but
>> I can't prevent the ctrl-s character from inserting into the text. How
>> can I do this?
>
> use strict;
> use warnings;
>
> use Tk;
> my $mw = tkinit;
> my $t = $mw->Text->pack;
> $t->bindtags(['MyTag',$t->bindtags]);
> $mw->bind('MyTag', '', \&save);
>
> MainLoop;
>
> sub save{
>      print "saving\n";
>      Tk::break; ...
Show full article (2.50Kb)
no comments
Re: preventing accelerators from inserting into text widget         


Author: Ch Lamprecht
Date: Mar 31, 2008 01:24

fossildoc wrote:
> On Feb 28, 4:03 am, Ch Lamprecht wrote:
>
>>fossildoc wrote:
>>
>>>I use a ctrl-s accelerator to save the contents of a text widget, but
>>>I can't prevent the ctrl-s character from inserting into the text. How
>>>can I do this?
>>
>>use strict;
>>use warnings;
>>
>>use Tk;
>>my $mw = tkinit;
>>my $t = $mw->Text->pack;
>>$t->bindtags(['MyTag',$t->bindtags]);
>>$mw->bind('MyTag', '', \&save);
>>
>>MainLoop;
>> ...
Show full article (2.88Kb)
no comments
Re: preventing accelerators from inserting into text widget         


Author: fossildoc
Date: Mar 31, 2008 10:27

Hi, Christoph -

Thanks again for responding. Below is the entire sub which contains
the problem. open_annotation_file() is a callback for a menu choice in
a "jpeg document window" Toplevel, whose address is passed to the sub.
Recall that when open_annotation_filie()is called a second time, a new
Toplevel and text widget are created and loaded with the appropriate
file, but that pressing a key while that second text widget's Toplevel
is active will cause the the anonymous sub to reference values from
the first text widget's Toplevel. There are no global variables. I
suspect the problem lies in the relationship between the Subwidget()
return value and bindtags(), neither of which I fully understand, as
the documentation is cryptic. I am running XP Home.
Show full article (6.69Kb)
no comments
Re: preventing accelerators from inserting into text widget         


Author: Lamprecht
Date: Mar 31, 2008 14:58

fossildoc schrieb:
> Hi, Christoph -
>
> Thanks again for responding. Below is the entire sub which contains
> the problem. open_annotation_file() is a callback for a menu choice in

Hi,

that's far too much code... And still not enough ;)
Does this behave the way you want:

Christoph

use strict;
use warnings;
Show full article (0.70Kb)
no comments