Skip to content

Commit

Permalink
messageBox.t: alternative approach for X11
Browse files Browse the repository at this point in the history
Avoid using Perl exit() in after callback
See #14
  • Loading branch information
chrstphrchvz committed May 15, 2022
1 parent 75a3e98 commit cd08f42
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions t/messageBox.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ my $top = MainWindow->new(-title => 'MessageBox Test');
$top->after(1000,
sub{
if( $top->windowingsystem eq 'x11' ){
ok(1);
exit(); # No using $top->destroy here, because we get grab error messages on X11
# But if we use this on windows, we get crashes.

# No using $top->destroy here, because we get grab error messages on X11
my $msgbox = $top->interp->widget(
'.__tk__messagebox', # implementation detail; see msgbox.tcl
'Tcl::pTk::Toplevel',
);
$msgbox->focus;
$msgbox->eventGenerate('<Escape>');
}
else{
$top->destroy(); # This works without errors on windows
Expand Down

0 comments on commit cd08f42

Please sign in to comment.