... use Scalar::Util; use Glib qw(TRUE FALSE); ... sub _init { ... # Creating the "Ok"-button $button_ok = Gtk2::ToolButton->new( undef, 'Ok' ); $self->{ButtonOk} = $button_ok; # Connecting the signal-handler to it $button_ok->signal_connect( 'clicked' => sub { $self->_ok_pressed( @_ ) } ); } # The signal handler sub _ok_pressed { my ( $self, $button, $event ) = @_; # Make button and event object properties to have them available outside the # signal handler's scope $self->{EventHash}->{Button} = $button; $self->{EventHash}->{Event} = $event; # Clear the summary, navigate to other notebook page ... } # The _save_work subroutine sub _save_work { # Parameter processing, declarations, etc. ... # The actual loop which waits for the event while ( TRUE ) { # Give the main loop the chance to intercept events with the program # being in this loop while ( Gtk2->events_pending() ) { Gtk2->main_iteration(); } if ( %{$self->{EventHash}} ) { # This checks whether the expected TYPE of event ocurred and whether it # was passed to the expected WIDGET (the "Ok"-button) if ( ( refaddr( $self->{EventHash}->{Button} ) == refaddr( $self->{ButtonOk} ) ) && ( defined( $self->{EventHash}->{Event}->{'type'} ) ) && ( $self->{EventHash}->{Event}->{'type'} eq 'button_press' ) && ( $self->{EventHash}->{Event}->{'button'} == 1 ) ) { # Code executed after pressing the "Ok"-button goes here ... $self->{EventHash} = (); last; } } } }