Re: can_activate_acce
- From: zentara <zentara zentara net>
- To: gtk-perl-list gnome org
- Subject: Re: can_activate_acce
- Date: Fri, 22 Jul 2005 11:05:11 -0400
On Wed, 20 Jul 2005 17:46:22 -0400 (EDT)
justin+gnome dicatek com
Subject: can_activate_accel
To: gtk-perl-list gnome org
If I understand the documentation correctly, one should be able to disable
the keyboard accelerator for a widget by connecting to the
can_activate_accel signal and returning false. This isn't working for me,
however.
Can someone tell me if I'm doing something wrong, or is there a bug in
gtk/gtk-perl? Example program below... using gtk 2.4.9 and gtk-perl 1.092,
typing a "b" in the text entry will click the button despite the
can_activate_accel handler.
Hi, this is how I got it working, however, I'm just learning myself. There
probably is a more elegant solution.
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 qw(-init);
my $window = Gtk2::Window->new;
my $button = Gtk2::Button->new('button');
my $entry = Gtk2::Entry->new;
my $vbox = Gtk2::VBox->new(0,2);
my $accel = Gtk2::AccelGroup->new;
$window->add($vbox);
$vbox->pack_start($button,1,1,0);
$vbox->pack_start($entry,1,1,0);
$button->add_accelerator('clicked', $accel, ord('b'), [], [] );
$window->add_accel_group($accel);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$button->signal_connect(clicked => sub { print "clicked\n"; });
#$button->signal_connect(can_activate_accel => sub { return 0; });
$entry->signal_connect (event => sub {
my ($item, $event) = @_;
if( $event->type eq 'enter-notify'){
Gtk2::AccelGroup::disconnect_key($accel, ord('b'),[]);
}
if( $event->type eq 'leave-notify'){
$button->add_accelerator('clicked', $accel, ord('b'), [], [] );
}
});
$window->show_all;
Gtk2->main();
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]