Gtk2::Entry and signals



Hi,

I have an entry in which a user has to input a date like this in this format
DD/MM/YYYY.
When the user starts to type the date (let's say it is 28/01/2004 - today)
he begins with 2 then in the entry we get 
2D/MM/YYYY and the non decimal chars are selected
 ^^^^^^^^^
Next he/she presses 8 and we get
28/MM/YYYY
  ^^^^^^^^
and so on..

I attached a signal to his entry:

my $e = Gtk2::Entry->new;
my $handle_id = $e->signal_connect( changed => \&_check_data_);
$e->{handle_id} = $handle_id;
        

sub _check_data_ {
        my ($e) = @_;

        my $pos  = $e->get_position;
        my $text = $e->get_text;
        $text =~ s{//}{/};

        my ($z, $l, $a) = split '/', $text;
        $text = 'DD/MM/YYYY';

        if ($d && $d =~ /(\d{1,2})/) {$text =~ s/DD/$d/}
        if ($m && $m =~ /(\d{1,2})/) {$text =~ s/MM/$m/}
        if ($y && $y =~ /(\d{1,4})/) {$text =~ s/YYYY/$y/}

        $e->signal_handlers_block_by_func('_check_data_');
#       print $e->handler_is_connected($e->{handle_id});  #!! -this fails
#       $e->signal_handlers_block($e->{handle_id});               #!! -this fails


#       $e->set_text($text);                                                      #!! -change the text
        $e->set_position($pos);
        $e->select_region($pos, length $text);


#       $e->signal_handlers_unblock($e->{handle_id});    
        $e->signal_handlers_unblock_by_func('_check_data_');
        $e->signal_stop_emission_by_name('changed');
};

        
I found an example in C API of GtkEditable on how to force an entry to 
uppercase. It didn't work as expected () and than I tried to use the method
signal_handlers_block() but this one failed.

Can you, please, tell me what do I miss?
Tnx,
Cornel



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