Re: How to disable all keys except <Enter>?



On Thu, 29 Mar 2007 12:29:30 +0200
Lumir Jasiok <lumir jasiok vsb cz> wrote:

Hi,

I need to disable in my program all keyboard events excluding <Enter> 
key. I need to disable the GNOME keyboard shortcuts etc. It should look 
like gksu application. Is there any way to do this? I'm trying this code 
(stolen from gtk2-perl study guide):

But without success. It looks like the &disable_keys function isn't 
called by 'key-press-event'. What I am doing wrong?

Regards
Lumir

Hi, this works for me on linux.

#!/usr/bin/perl
use warnings;
use strict;
use Gtk2;
use Glib qw/TRUE FALSE/;
use Gtk2::Gdk::Keysyms;
use Gtk2 -init;

my $window = Gtk2::Window->new;

$window->signal_connect( 'key_press_event' => \&process_entry_keypress );
$window->signal_connect( 'destroy' => sub { Gtk2->main_quit } );

$window->show;

Gtk2->main;

sub process_entry_keypress {
 
    my ( $widget, $event ) = @_;
   
    if (
        $event->keyval == $Gtk2::Gdk::Keysyms{ Return } ||
        $event->keyval == $Gtk2::Gdk::Keysyms{ KP_Enter }
       ) {
        print "An Enter key has been pressed!\n";
    }
   
    return FALSE;
   
}
__END__


zentara

__________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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