Re: How to Add a Keyboard Accelarator to a Button



Thanks!

But will the accelarator group mess with my Menu's accelarators?

Regards,

        Shlomi Fish

On Fri, 22 Jun 2001, Liviu BURCUSEL wrote:

 Here is a demo programm ...

#! /usr/bin/perl -w

use strict;
use Gtk;

Gtk->init();

my $win = new Gtk::Window 'toplevel';
$win->signal_connect('delete_event', sub {Gtk->main_quit(); return
0;});

my $accel_group = Gtk::AccelGroup->new();
$accel_group->attach($win);

my $vbox = Gtk::VBox->new();

my $butt = Gtk::Button->new('_Whatever');
## the following line does the underlining and get the shortcut
letter.
my $acc = $butt->child->parse_uline('_Whatever');
## i define the accelerator
$butt->add_accelerator('clicked', $accel_group, $acc, 'mod1_mask',
['visible', 'locked']);


$butt->signal_connect('clicked', \&button_clicked);
$vbox->add($butt);
$win->add($vbox);

$win->show_all();

Gtk->main();

exit(0);

sub button_clicked {
    warn "I was clicked";
}

## end of script


Liviu

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list




----------------------------------------------------------------------
Shlomi Fish        shlomif vipe technion ac il 
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       shlomif techie com

A more experienced programmer does not make less bugs. He just realizes
what went wrong more quickly.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]