confused about keyboard focus
- From: tjic tjic com (Travis J.I. Corcoran)
- To: gtk-perl-list gnome org
- Subject: confused about keyboard focus
- Date: 30 Dec 2005 15:11:47 -0500
I'm confused about keyboard focus. I'm writing code that I *think*
should make one specific widget receive keyboard input, yet when I
type at the screen, the keyboard input goes somewhere else.
I've got a big gtk2 app, but I've boiled the issue down to a simple
demo program:
#!/usr/bin/perl -w
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub { Gtk2->main_quit });
my $vbox = new Gtk2::VBox( FALSE, 0 );
my $entry1 = Gtk2::Entry->new();
my $entry2 = Gtk2::Entry->new();
$entry2->has_focus(TRUE); # <---- IMPORTANT LINE
$vbox->pack_start( $entry1, FALSE, FALSE, FALSE );
$vbox->pack_start( $entry2, FALSE, FALSE, FALSE );
$window->add ($vbox);
$window->show_all;
Gtk2->main;
I would expect that when the gtk2 application was focused, any
characters I'd type would end up in 'entry2' gtk2::entry.
...but they don't. They end up in 'entry1'.
1) Why?
2) How do I accomplish my goal of making one widget receive keyboard
input with out (a) making it first on the screen ; (b) requiring the
user to click or tab around?
Thanks in advance!
TJIC
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]