From cd08f420e1f5437fc20e72e63d9ee2793f4e0e9e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Sun, 15 May 2022 14:22:41 -0500 Subject: [PATCH] messageBox.t: alternative approach for X11 Avoid using Perl exit() in after callback See #14 --- t/messageBox.t | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/t/messageBox.t b/t/messageBox.t index d761ea9..f32c88f 100644 --- a/t/messageBox.t +++ b/t/messageBox.t @@ -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(''); } else{ $top->destroy(); # This works without errors on windows