Re: [gtk-list] Re: gnome-perl: signal_connect_after



On 2000-01-19 06:59:10 -0800, Paolo Molaro dared put this in front of me:

> Check Gtk/xs/GtkObject.xs: with XS code it's possible to use
> aliases, perl sets the ix variable according to how the function
> was called.
> Try for yourself this example with and without s/_after//.

In that case, the only option thats left is a flaw in my code, but I can't
seem to find it.
Here's a snippet of the relevant section (the 'activate' handler is
commented out since I found the spacebar was triggering it when I added the
key_press_event handler; i now call the activate handler explicitly from
the key_press_event handler on a Return keypress):

sub new {
#...
    $input_line->signal_connect_after('key_press_event', 
				      \&input_key_pressed_event, 
				      $self);
#    $input_line->signal_connect('activate', \&input_line_activated,
$self);
#...
}

#...

sub input_key_pressed_event {
    my ($entry, $self, $event) = @_;

    print "key pressed!\n";
    if ($event->{keyval} == $Gtk::Keysyms{Up}) {
	$entry->set_text($self->{cmd_hist}->[++$self->{cmd_ptr}])
	    if $self->{cmd_ptr} < @{$self->{cmd_hist}};
	$entry->grab_default;
	$entry->grab_focus;
    } elsif ($event->{keyval} == $Gtk::Keysyms{Down}) {
	$entry->set_text($self->{cmd_hist}->[--$self->{cmd_ptr}])
	    if $self->{cmd_ptr} > 0;
	$entry->grab_default;
	$entry->grab_focus;
    } elsif ($event->{keyval} == $Gtk::Keysyms{Return}) {
	input_line_activated($entry, $self);
    }

    return 0;
}

Thanks again,
James



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