From: Peter <lan...@fr...> - 2006-02-23 08:14:58
|
Hi Guys, A simple question this time... I put a simple PhotoViewer Sample based on the PhotoViewer class I wrote for VideoBox on the Wiki (when it happened to be up). It's controlled by keypresses, n is next, p is previous and so on. On Win32 I used accelerators for that. When trying the sample on Linux (Ubuntu, wxPerl 0.27, Perl 5.8.7) I noticed the the keys didn't work. Predictable because the WxWindows docs say for wxAcceleratorTable: "on GTK, only menu commands are supported". :( So I tried to create a menu. That worked, but unfortunately, when putting the viewer into fullscreen and hiding the menu (you don't want a menu in a fullscreen photo viewer) the keys didn't work anymore either... :( My last option was to use the EVT_KEY_* functions to try and detect keystrokes, but I couldn't get that to work on GTK. The minimal code below works well under Win32, but it doesn't detect any keystrokes under Linux. Is there no way to read keyboard events under GTK apart from menu accelerators or have I done something wrong that I can get away with under Win32 but bites me under Linux? Thanks for any help. Regards, Peter PS: I'll document the answer in the Wiki if it ever regains life. #!/usr/bin/perl package MyApp; use base 'Wx::App'; use Wx ':everything'; use Wx::Event ':everything'; sub OnInit { my $frame = Wx::Frame->new( undef, undef, undef, [-1,-1], [200,200] ); $frame->Show( 1 ); EVT_KEY_DOWN( $frame, sub { printf "Key pressed %d\n", $_[1]->GetKeyCode } ); 1; } MyApp->new()->MainLoop(); |