trying to get keypresses in an OptionMenu

I've got an OptionMenu that is unwieldy to scroll through - it has
approximately 2,000 choices.

It occurred to me that allowing the user to type a character, and then
jumping to an appropriate entry ( through OptionMenu::set_history() )
would help a lot.

The problem I have is that I don't know how to get the
'key-press-event' signal to reach the menu object.

I can configure a handler on the signal, via 

         my $menu = Gtk2::Menu->new();
         my $opt = Gtk2::OptionMenu->new();

         my $handlerID = $opt->signal_connect( 'key-press-event',
                                                                                   sub (@) { 
                                                                                   my ($a, $b) = @_;
                                                                                   print  "here! ". join(",", 
($a,$b)) ."\n"; 


And when I tickle that manually, via 

         my $ee = Gtk2::Gdk::Event::Key->new('GDK_KEY_PRESS');
         $opt->signal_emit('key-press-event', $ee);

everything works as I would expect.

I know that Gtk2::OptionMenu does not, by default, support the
'key-press-event', so I added this code:

         $opt->add_events( ['key-press-mask', 'key-release-mask'] );

but that doesn't seem to help.  Nor does

         $opt->add_events( 'GDK_ALL_EVENTS_MASK' );


I tried connecting an event handler to the generic event:

         my $handlerID2 = $opt->signal_connect( 'event' ...);

and that printed out lots of events of type Expose, Crossing, Button,
etc., but I could not get it to show an event of type

...and now I've run out of ideas.

Can anyone help?



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