Gtk2::Assistant: Access to Buttons



A program I wrote uses the new Assistant widget on sevaral occasions.

To make usage as convenient as possible, I would like the return key to always
do the next logical step (focus the next entry field or trigger the "forward"
button)

Below is a minimal code example with one single entry on the 1st page. It would
be nice to just enter some text into the entry and hit return to go on.

Unfortunately, I can't figure out how to access the buttons (so I could
call $button->clicked() in response to a Return key press) or any other way
to do this (something like $assistant->signal_emit('forward') maybe).

Any Ideas?
Regards,
                           Peter Daum


use Gtk2 -init;

my $assistant = Gtk2::Assistant->new();
foreach my $sig qw(cancel close apply delete_event) {
   $assistant->signal_connect ($sig => sub { Gtk2->main_quit() } );
}

my $page = Gtk2::VBox->new(0,0);
my $l = Gtk2::Label->new("Wouldn't it be nice to just hit return to go on?");
my $e1=Gtk2::Entry->new();
$page->pack_start($l,0,0,5);
$e1->set_activates_default(1); #?
$page->pack_start($e1,1,1,5);
$assistant->append_page($page);
$assistant->set_page_type ($page, 'content');
$assistant->set_page_title ($page, "1");
$assistant->set_page_complete ($page, 1);

$page = Gtk2::Label->new('Confirm');
$assistant->append_page($page);
$assistant->set_page_type ($page, 'confirm');
$assistant->set_page_title ($page, "2");
$assistant->set_page_complete ($page, 1);

$assistant->show_all();
Gtk2->main;
exit( 0 );




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