propagate_key_event



Can the propagate_key_event method in Gtk2::Window be used to feed a
key-press to a window?

I have a FileChooser dialog which will close if I press the Escape key
but not if I try and generate it synthetically:

  my $event = Gtk2::Gdk::Event::Key->new('key-press');
  $event->keyval($Gtk2::Gdk::Keysyms{'Escape'});
  $dialog->propagate_key_event($event);


The reason I'm trying to do this is I have a regression test which
activates a button which pops up the dialog.  The fact the the dialog
appears is good enough for me, but my test script stops at that point
waiting for the dialog to be closed.

I did achieve my aim by getting a handle on the dialog window, walking
through the tree of child widgets to find the cancel button and then
calling its 'clicked' method.  Although it did do the job, I get a
series of errors like this printed out:

  GType 'GtkFileChooserDefault' is not registered with GPerl;
  representing this object as first known parent type 'GtkVBox' 
  instead at t/lib/TestView.pm line 42.

Of course as I write this, I realise that Gtk2::Dialog has a 'response'
method which does exactly what I want.  Duh!

Anyway, what's that propagate_key_event thing for anyway?

Cheers
Grant







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